Open
Description
Nested test docs: https://junit.org/junit5/docs/current/user-guide/#writing-tests-nested
Currently snapshot matching within nested test classes is not supported.
Example:
class Demo {
@BeforeAll
static void beforeAll() {
SnapshotMatcher.start();
}
@AfterAll
static void afterAll() {
SnapshotMatcher.validateSnapshots();
}
@Test
void one() {
expect("one").toMatchSnapshot(); // succeeds
}
@Nested
class NestedTest {
@Test
void two() {
expect("two").toMatchSnapshot(); // fails
}
@Nested
class DeeplyNestedTest {
@Test
void three() {
expect("three").toMatchSnapshot(); // fails
}
}
}
}
Stack trace:
io.github.jsonSnapshot.SnapshotMatchException: Could not find method two on class class java.lang.Object
Please annotate your test method with @Test and make it without any parameters!
at io.github.jsonSnapshot.SnapshotMatcher.lambda$getMethod$4(SnapshotMatcher.java:174)
at java.util.Optional.orElseThrow(Optional.java:290)
at io.github.jsonSnapshot.SnapshotMatcher.getMethod(SnapshotMatcher.java:172)
at io.github.jsonSnapshot.SnapshotMatcher.lambda$getMethod$3(SnapshotMatcher.java:171)
at java.util.Optional.map(Optional.java:215)
at io.github.jsonSnapshot.SnapshotMatcher.getMethod(SnapshotMatcher.java:171)
at io.github.jsonSnapshot.SnapshotMatcher.expect(SnapshotMatcher.java:99)
Metadata
Metadata
Assignees
Labels
No labels