Ask Question

How to write snapshot tests in Java?

I've changed a SQL Query which is executed by my Java Application and which shouldn't change the result set, but only give a performance boost to the query. Now I would like to do an integration test if the data returned from the new query equals to the new query.

In JavaScript I would use Snapshot assertions with Jest, where I execute the test with the old query, create the snapshot and then execute the same test with the old query and check if the snapshots are the same.

Is there a same way to create and assert snapshots in Java?



Authorยดs Dominik Sumer image

Dominik Sumer

Last edited on

1 Answer available

Best answer

I found the following json-snapshot library which does exactly what I need: