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

Unable to Run Test Suite Class Not Enclosed #54

Closed
D3Castro opened this issue Sep 19, 2022 · 6 comments · Fixed by #87
Closed

Unable to Run Test Suite Class Not Enclosed #54

D3Castro opened this issue Sep 19, 2022 · 6 comments · Fixed by #87

Comments

@D3Castro
Copy link

I'm attempting to run test suites using sbt test, however, I am unable to resolve a runtime exception from the dispatcher. I've created the below repository to replicate the issue.
https://github.com/D3Castro/Junit5ModuleTestSuite

[error] WARNING: TestExecutionListener [net.aichler.jupiter.internal.event.Dispatcher] threw exception for method: executionFinished(TestIdentifier [uniqueId = [engine:junit-platform-suite]/[suite:com.test.TestSuite]/[engine:junit-jupiter]/[class:com.test.junit.SimpleClassTest], parentId = [engine:junit-platform-suite]/[suite:com.test.TestSuite]/[engine:junit-jupiter], displayName = 'SimpleClassTest', legacyReportingName = 'com.test.junit.SimpleClassTest', source = ClassSource [className = 'com.test.junit.SimpleClassTest', filePosition = null], tags = [], type = CONTAINER], TestExecutionResult [status = SUCCESSFUL, throwable = null])
[error] java.lang.RuntimeException: Test class com.test.junit.SimpleClassTest is not enclosed by com.test.TestSuite
[error] at net.aichler.jupiter.internal.event.TaskName.nestedSuiteId(TaskName.java:135)
[error] at net.aichler.jupiter.internal.event.TaskName.of(TaskName.java:110)
[error] at net.aichler.jupiter.internal.event.Dispatcher.lambda$executionFinished$2(Dispatcher.java:99)
[error] at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
[error] at net.aichler.jupiter.internal.event.Dispatcher.executionFinished(Dispatcher.java:95)
[error] at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$executionFinished$10(CompositeTestExecutionListener.java:69)

@maichler
Copy link
Contributor

maichler commented Sep 21, 2022 via email

@D3Castro
Copy link
Author

Is there anything related to the setup which may be causing this that I could investigate?

@maichler
Copy link
Contributor

I think the issue is caused by using @Suite, which is part of the relatively new suite support in JUnit 5. Suite support comes with its own engine (engine:junit-platform-suite) which modifies the test identifier in such a way that TaskName can't handle it correctly anymore and makes the wrong assumptions.

To be sure I have to investigate a bit more and try to isolate it in a test case to see how we can fix it. But this might take a while I'm afraid.

Best bet for a short term solution would be to not use @Suite for now, if that's possible.

@kamilkloch
Copy link

Any chances for @Suite support? :)

@Nezisi
Copy link
Contributor

Nezisi commented Jun 5, 2023

The original problem is - like @maichler explained – that TaskName cannot handle the name.
TaskName was added to handle nested tests (@Nested annotation) properly.

Credit for the idea behind the fix goes to @maichler, too.

As the JUnit 5 suite support is added via an own engine, we can just extend the check in TaskName for the nested tests to additionally check if the test engine is the JUnit5-Engine.

Just to be on the safe side, I added nested tests inside the suite definition and the test ran by the suite definition to make sure I didn't break it.

Nezisi/sbt-jupiter-interface@bump-sbt-1_8...Nezisi:sbt-jupiter-interface:fix-junit5-suite-support

The PR is based up on the SBT 1.9 pull request, I'll wait with the PR until it's merged.

eed3si9n added a commit to eed3si9n/sbt-jupiter-interface that referenced this issue Jul 28, 2024
@eed3si9n
Copy link
Member

Here's #87, which takes the above branch and applies it on top of main now that I've bumped sbt version etc.

eed3si9n added a commit to eed3si9n/sbt-jupiter-interface that referenced this issue Jul 28, 2024
eed3si9n added a commit that referenced this issue Aug 16, 2024
* Reproduce #54

* Dispatcher: Use NestedSuiteSelector / NestedTestSelector (SBT 1.3)

* Configuration: test identifier: filter out identifiers not containing source

- e.g. the platform (skipped by path.stream().skip(1)
- e.g. for JUnit 5 suites the engine used to start the test in the test suite

* TaskName: remove JUnit 5 suite name if present, add tests

* Adjust the expected value

---------

Co-authored-by: H. Habighorst <h.habighorst@protonmail.com>
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

Successfully merging a pull request may close this issue.

5 participants