Extending Spock
(into the Future)
* Question: Who is using Spock?
* Question: Who has never used Spock?
* Spock is awesome already ;)
* Repeating Code
* Provide a library integration
* Do something not possible with standard options
* The first question you face
@Stepwise
class MySpec extends Specification {
}
class MySpec extends Specification {
@AutoCleanup
FileReader reader
@IgnoreIf({ os.windows })
def "only runs on non-windows hosts"(){
//...
}
}
class MySpec extends Specification {
@Rule
TemporaryFolder temporaryFolder
}
Allows to adapt third-party code.
@SpringBootTest
class MySpec extends Specification {
}
Allows to adapt third-party code.
* Perform some side effects
* get started
* look for similar
More Information
http://spockframework.org/spock/docs/1.3/extensions.html
* Question who is still using Java 8
* Java 11/12?
* Older versions?
class Spock2 extends Specification {
def "maximum of two numbers #a, #b = #c" (int a, int b, int c) {
expect:
Math.max(a, b) == c
where:
a | b | c
1 | 3 | 3
7 | 4 | 7
0 | 0 | 0
}
}
Questions?
https://github.com/spockframework/spock-gr8conf-2019