Verify no exceptions were thrown in Spock
11,184
Found it.
You can use
noExceptionThrown()
To assert nothing was thrown
Author by
smeeb
Updated on June 17, 2022Comments
-
smeeb almost 2 years
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?