You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After importing a Maven project to Metals, it doesn't show lenses for JUnit test classes, as well as for ZIO specs which piggyback on JUnit machinery as described here.
Reproduction
(This example focuses on running tests via Bloop CLI, but the root reason is the same, and fixing one leads to fixing the other)
Consider this Maven project: example.zip. It includes a single
failing test that requires JUnit to run. Maven understands this:
After importing the project to Bloop as described here, we can attempt to run the tests, but Bloop doesn't recognize them:
$ bloop test my-artifact-test
...
[E] Missing configured test frameworks in my-artifact-test
===============================================
Total duration: 0ms
No test suites were run.
===============================================
The missing piece seems to be the JUnit-SBT bridge (com.novocode:junit-interface:0.11) - after adding the corresponding dependency (by uncommenting it in pom.xml) and reimporting the project, we get the desired result:
$ bloop test my-artifact-test
...
===============================================
Total duration: 9ms
1 failed
Failed:
- BarTest:
* BarTest.evaluatesExpression - java.lang.AssertionError: expected:<4> but was:<5>
===============================================
Note that this is inconvenient, since it requires modifying the Maven project and preserving the change for later imports, either by pushing it upstream with the corresponding review process, or by inventing some way to "keep it alive" locally for future imports. I'm not aware of a palatable way to add a dependency to an existing Maven project without modiying pom.xml (like a local .sbt file in SBT).
The text was updated successfully, but these errors were encountered:
Thanks for reporting! Bloop uses the same mechanism for tests as sbt and without junit-interface class it's unable to use the junit test framework. We might want to add the interface if it's missing in the project, though I am not sure if it's the perfect solution 🤔
Symptoms
After importing a Maven project to Metals, it doesn't show lenses for JUnit test classes, as well as for ZIO specs which piggyback on JUnit machinery as described here.
Reproduction
(This example focuses on running tests via Bloop CLI, but the root reason is the same, and fixing one leads to fixing the other)
Consider this Maven project: example.zip. It includes a single
failing test that requires JUnit to run. Maven understands this:
$ mvn test ... [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 ...
After importing the project to Bloop as described here, we can attempt to run the tests, but Bloop doesn't recognize them:
The missing piece seems to be the JUnit-SBT bridge (
com.novocode:junit-interface:0.11
) - after adding the corresponding dependency (by uncommenting it inpom.xml
) and reimporting the project, we get the desired result:Workaround
Add this dependency to your pom.xml:
Note that this is inconvenient, since it requires modifying the Maven project and preserving the change for later imports, either by pushing it upstream with the corresponding review process, or by inventing some way to "keep it alive" locally for future imports. I'm not aware of a palatable way to add a dependency to an existing Maven project without modiying
pom.xml
(like a local.sbt
file in SBT).The text was updated successfully, but these errors were encountered: