I am brand new to Spock and perused their online docs. I have a test case where I need to verify that my fixture's interaction with a non-mock collaborator does not produce an exception:
class FizzSpec extends Specification { def "no exception thrown when we hail buzz"() { given: Fizz fixture = new Fizz() Buzz buzz = new Buzz("YES", true, "Garble barb") // A non-mock! when: fixture.hail(buzz) // TODO: How to verify the hail didn't produce an exception? // then: // thrown() == null } }
Any ideas as to how I can accomplish this?
Found it.
You can use
noExceptionThrown()
To assert nothing was thrown
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With