spock
Post on 15-Aug-2015
9 Views
Preview:
TRANSCRIPT
SpockAbid H Khan
Agenda● Benefits of unit testing● Other testing framework● Spock Basics● Walkthrough
Benefits of unit testing● Reduces bugs in production,reduces cost● Reduces development time● Increase confidence● can executes test cases frequently● Measures completion● Provides documentations● Improves design
Other testing frameworks● JUnit● TestNG
Spock Basics● Specification● Building blocks
o Fieldso Fixture methodso Feature methodso Helper methods
Spock:Fields● Instance Fields
def pageNo=0def request = new GroupRequestDto()
● Shared Fields@Shared
@AutoCleanupRESTClient restClient
● Static Fieldsstatic final SUCCESS=200;
Spock:Fixture methods● def setup() {} ● def cleanup() {} ● def setupSpec() {} ● def cleanupSpec() {}
Spock:Feature methods● setup● when● then● expect● cleanup● where
Vs JunitSpock Junit
Specification Test class
setup() @Before
cleanup() @After
setupSpec() @BeforeClass
cleanupSpec() @AfterClass
Feature Test
Parameterized feature Theory
Condition Assertion
Exception condition @Test(expected=...)
@FailsWith @Test(expected=...)
Interaction Mock expectation (EasyMock, JMock, ...)
Walkthrough
References● Spock Basics
https://code.google.com/p/spock/wiki/SpockBasics
● Benefits of Unit Testinghttp://sd.jtimothyking.com/2006/07/11/twelve-benefits-of-writing-
unit-tests-first/
top related