4. Spock usa o JUnit runner
• Como incluir testes spock em meu projeto?
• Como rodar testes spock?
• Como debugar testes spock
• Como visualizar a cobertura de testes?
• como integrar testes spock com o sonar?
• como eu…?
8. @Shared res = new VeryExpensiveResource()
static final PI = 3.141592654
Anotação @Shared
9. Fixture Methods
def setup() {} // run before every feature method
def cleanup() {} // run after every feature method
def setupSpec() {} // run before the first feature
method
def cleanupSpec() {} // run after the last feature
method
15. Cleanup Blocks
setup:
def file = new File("/some/path")
file.createNewFile()
// ...
cleanup:
file.delete()
• Um bloco Cleanup só pode ser seguido por um bloco
where
• Normalmente usados para fechar uma conexão com
banco de dados ou outro recurso.
16. Where Blocks
def "computing the maximum of two numbers"() {
expect:
Math.max(a, b) == c
where:
a << [5, 3]
b << [1, 9]
c << [5, 9]
}
19. Specifications as Documentation
setup: "open a database connection"
// code goes here
// code goes here
and: "seed the customer table"
// code goes here
and: "seed the product table"
// code goes here