Writing Tests with Spock

Learn about the Spock testing framework by creating a project that uses Spock to unit test Java code

rcg-thumbnail
Data Pipes
Often we want to test the same set of criteria with different sets of data. Data pipes is one mechanism to do this.
rcg-thumbnail
Data Tables
Data tables offer the same functionality as data pipes, but this syntax can sometimes be more readable for more complex sets of data.
rcg-thumbnail
Mocks
Mocks are a useful testing tool. We can provide "empty" objects, so we don't have to initialise the whole application to test a section, and we can use mocks to check our code is making the calls we expect.
rcg-thumbnail
Stubs
Stub objects allow us to state from a test what values get injected into our application code. They can provide simple interfaces, so we don't have to initialise the whole application to test a section.
rcg-thumbnail
Helper Methods
Sometimes we need to move test code into a separate method. In this section, we look at some tips for this.
rcg-thumbnail
With
Sometimes we want to check more than one value on an object. We can use `with` to do this.
rcg-thumbnail
Verify All
Test frameworks often stop the test at the first failure. Find out how to run all conditions to see which pass and which fail.