maxbechtold/golden-master

@Test methods with @GoldenMasterRun annotation fail

maxbechtold opened this issue · 2 comments

It doesn't matter if there are methods annotated with @GoldenMasterRun or not.

Observed with golden-master 0.6-SNAPSHOT.

Stacktrace:

Suppressed: java.lang.NullPointerException
		at maxbe.goldenmaster.approval.ApprovalIdResolver.getApprovalId(ApprovalIdResolver.java:21)
		at maxbe.goldenmaster.approval.ApprovalIdResolver.resolveApprovalIdFor(ApprovalIdResolver.java:16)
		at maxbe.goldenmaster.junit.extension.RunInvocationContextProvider.afterEach(RunInvocationContextProvider.java:97)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterEachCallbacks$11(TestMethodTestDescriptor.java:245)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$12(TestMethodTestDescriptor.java:256)
		at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:256)
		at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:255)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachCallbacks(TestMethodTestDescriptor.java:244)
		at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:141)
		... 43 more

This is a problem with annotations - if more than one TestDescriptor exists (which JUnit prints a warning for), all descriptors will be handled by the harness. This fails since it is designed to work with the GoldenMasterRun annotation

Example for reproduction:

@GoldenMasterRun
@Test
void aTestWithMultipleAnnotations() {
   ...
}