We assume that you follow some conventions that define where your test files are stored. You can either use our recommended conventions or define your own.
By default, the following conventions are assumed
- baseline paths may contain
.baseline, e.g.my-response.baseline.json - baselines are stored in
src/test/resourcessrc/testFixtures/resourcesvar/specs
- The actual output is saved in the same directory with
.actual.in the name - The argument of
.isEqualToBaseline(testKey)defines the relative path in the resource root. - you should add
path/to/your/test/resources/**/*.actual.*to your .gitignore
If you want to customize the baseline test behavior, you can do so using SPI.
Register your desired Convention in META-INF/services/io.github.goatfryed.assert_baseline.Convention.
See this example.
Note: Configuration of different resource roots is easy. More complex setups can be achieved, but we do not guarantee the stability of the internal api at the moment.
If you want to define your own convention, implement io.github.goatfryed.assert_baseline.Convention.
Usually, you want to do so by extending io.github.goatfryed.assert_baseline.convention.AbstractConvention
public class MyBaselineConvention extends AbstractConvention {
@Override
public String resolveActualPath(String requestedBaselinePath) {
return "src/test/resources/actual/" + requestedBaselinePath;
}
@Override
public String resolveActualPath(String requestedBaselinePath) {
return "src/test/resources/expected/" + requestedBaselinePath;
}
}This would allow you to call assertThatJson(event).isEqualToBaseline(event.json)
and have the actual file stored as src/test/resources/actual/event.json and compared with
src/test/resources/expected/event.json