| Use Case | Conventional Tool(s) | A Single Tool |
|---|---|---|
| Unit Testing | JUnit TestNG |
Spock |
| Mocking and Stubing |
EasyMock jMock Mockito PowerMock jMockit |
|
| Behaviour Driven Design (BDD) |
Cucamber JBehave |
| JUnit | Spock |
|---|---|
| Test class | Specification |
| Test | Feature |
| Test method | Feature method |
@Before |
setup() |
@After |
cleanup() |
| Assertion | Condition |
@Test(expected) |
Exception condition |
import spock.lang.Specification
class StarshipSpec extends Specification {
def "science officer of the starship Enterprise is Spock"() {
given:
def starship = new Starship("Enterprise", "Spock")
when:
def actual = starship.getScienceOfficer()
then:
actual == "Spock"
}
}
Other blocks: expect, where
This work was supported by