Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.spun.util.FormattedException: Didn't find ... under target/fork_dir_2 when running from maven-surefire-plugin #608

Open
d-led opened this issue Jan 17, 2025 · 1 comment

Comments

@d-led
Copy link

d-led commented Jan 17, 2025

Problem

when running approval tests (JUnit5, Java 17) from mvn test via the maven-surefire-plugin, the tests fail with

com.spun.util.FormattedException: Didn't find com....BlaBlaTest under .../target/fork_dir_2
        at com.spun.util.ClassUtils.getSourceDirectory(ClassUtils.java:103)
        at com.spun.util.ClassUtils.getSourceDirectory(ClassUtils.java:108)
        at com.spun.util.tests.TestUtils.getInfo(TestUtils.java:195)
        at com.spun.util.tests.TestUtils.getCurrentFileForMethod(TestUtils.java:182)
        at com.spun.util.tests.TestUtils.getCurrentFileForMethod(TestUtils.java:174)
        at org.approvaltests.namer.StackTraceNamer.<init>(StackTraceNamer.java:17)
        at org.approvaltests.Approvals$1.load(Approvals.java:41)
        at org.approvaltests.Approvals$1.load(Approvals.java:38)
        at org.approvaltests.Approvals.createApprovalNamer(Approvals.java:265)
        at com.spun.util.ArrayUtils.getOrElse(ArrayUtils.java:309)
        at org.approvaltests.core.Options$FileOptions.getNamer(Options.java:120)
        at org.approvaltests.Approvals.verify(Approvals.java:191)
        at org.approvaltests.Approvals.verify(Approvals.java:50)
        at org.approvaltests.Approvals.verify(Approvals.java:46)
        at com....BlaBlaTest.unwrapping_for_storage_format(BlaBlaTest.java:34)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

[ERROR] com....BlaBlaTest.some_test

with maven, approvals and the plugin being latest ones. Earlier surefire plugin versions did not produce an insight into this stacktrace.

In IntelliJ the test run succeeds without any changes. Surefire seems to have a test run isolation feature, enabling the forks which might need a special treatment by approvals.

A work-around which helped me proceed: ↓

Workaround

<plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire.version}</version>
        <configuration>
            <workingDirectory>.</workingDirectory>
            <forkCount>0</forkCount>
            <!-- both config values make sure the tests pass in a controlled fashion -->
        </configuration>
</plugin>
@ScottBob
Copy link
Contributor

Not entirely sure how to replicate this as it is currently working on all of our GitHub actions. When we add your workaround it breaks things, so we don't want to do that. We'd be happy to join a call with you to understand the issue better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants