Skip to content

skrymer/spockshots

Repository files navigation


Spock Shots

Easily assert json using snapshots.

Table of Contents

About The Project

Adds json snapshot testing to spock and spring mockmvc tests. Allows assertion of json content using a snapshot file.

Built With

Getting Started

Get source by cloning repository:

git clone https://github.com/skrymer/spockshots.git

Usage

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
    }
}
  1. @Spockshot is optional, but will allow overriding of test root folder
  2. Use @Snapshot to specify the snapshot name
  3. Check that response matches snapshot

Roadmap

Move lib to maven repository

See the open issues for a list of proposed features (and known issues).

Contact

Sonni Nielsen - @sonni_nielsen

Project Link: https://github.com/skrymer/spockshots

Acknowledgements

About

Snapshot testing for spock

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages