I have a test spec in Spock
and I want to apply the same tests to another alternative with exception of one method. I extend the original spec, implement some custom stuff related to the alternative and would really like to exclude the execution of one test method.
I tried it with
@Ignore def "Something must work in a certain way"() { //No implementation }
but it seems that the method is called anyway.
Can this be achieved?
@Shared is a Spock feature that says to the reader that this variable is the same for all feature methods. It is an instruction specifically for the unit test and makes the unit test more clear for the reader.
lang. Specification class. A Spock specification can have instance fields, fixture methods, feature methods, and helper methods. We should prefer normal instance fields because they help us to isolate feature methods from each other.
Spock is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language. Thanks to its JUnit runner, Spock is compatible with most IDEs, build tools, and continuous integration servers.
Verify the import statement for @Ignore
. It should be imported from spock library instead of JUnit:
import spock.lang.Ignore
instead of
import org.junit.Ignore
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