Easily assert json using snapshots.
Adds json snapshot testing to spock and spring mockmvc tests. Allows assertion of json content using a snapshot file.
Get source by cloning repository:
git clone https://github.com/skrymer/spockshots.git
Use in combination with MockMvc:
@Spockshot(
rootFolder = "./src/test/groovy" #1
)
@WebMvcTest()
class ExampleSpec extends Specification {
@Autowired
MockMvc mockMvc
@Snapshot(name = 'snapshot') #2
def 'example feature'() {
when: 'getting data'
def response = mockMvc.perform(get("/api/example"))
then:
'data matches snapshot'
response.andExpect(matchesSnapshot()) #3
}
}
- @Spockshot is optional, but will allow overriding of test root folder
- Use @Snapshot to specify the snapshot name
- Check that response matches snapshot
Move lib to maven repository
See the open issues for a list of proposed features (and known issues).
Sonni Nielsen - @sonni_nielsen
Project Link: https://github.com/skrymer/spockshots