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

Support JUnit 5 #41

Open
olafurpg opened this issue Feb 3, 2020 · 10 comments
Open

Support JUnit 5 #41

olafurpg opened this issue Feb 3, 2020 · 10 comments
Labels
gradle help wanted Extra attention is needed junit5 Relating to JUnit 5 Upgrade

Comments

@olafurpg
Copy link
Member

olafurpg commented Feb 3, 2020

From https://contributors.scala-lang.org/t/announcing-munit-a-new-scala-testing-library/4007/11?u=olafurpg

It does not currently support JUnit 5, at least not with gradle – trying to run with org.junit.jupiter:junit-jupiter-engine doesn’t work, and instead the “vintage” engine has to be used.

I'm not so familiar with what is needed to make this work but I think it's worth looking into.

@eyalroth
Copy link

eyalroth commented Feb 3, 2020

It's worth noting that ScalaTest has a similar issue with what seem to be relevant information.

@olafurpg
Copy link
Member Author

olafurpg commented Feb 3, 2020

That’s good to know. Is there a way to support both JUnit 5 and 4 at the same time?

@eyalroth
Copy link

eyalroth commented Feb 4, 2020

I'm not sure. My guess would be that either the vintage engine (junit 4) knows how to work with (junit 5) extensions, or that each engine will exclusively use the appropriate method -- vintage will use runners, jupiter will use extensions -- so they can coexist.

I don't have any experience with extending junit myself, but this and this look like good guides on the topic.

@olafurpg olafurpg added the help wanted Extra attention is needed label May 10, 2020
@olafurpg olafurpg added this to the MUnit v1.0 milestone Oct 16, 2021
@olafurpg
Copy link
Member Author

olafurpg commented Oct 18, 2021

I've started working on an upgrade to JUnit 5 and hope to get a PR out soon.

I opened an issue for IntelliJ to confirm what changes are needed to keep the IntelliJ integration working https://youtrack.jetbrains.com/issue/SCL-19607

I have confirmed that the Gradle integration continues to work with useJUnitPlatform. The junit-vintage test engine will no longer be needed to run MUnit tests. Instead, the scalameta-munit test engine should be used and it's automatically registered as long as you depend on the MUnit artifact (you shouldn't need to explicitly declare the scalameta-munit test engine, unless you somehow disable automatic registration). I tried to see if it was possible to build on top of the junit-jupiter test engine but the API was too limiting.

I suspect this upgrade will also fix the incorrect HTML report issues in Gradle, although I haven't confirmed yet.

Overall, I'm really excited about this upgrade since JUnit 5 has a lot of nice improvements!

@armanbilge
Copy link
Contributor

Copy-pasting some Discord notes from Olafur:

The biggest change is how you notify updates, it's dramatically simpler with JUnit 5 while JUnit 4 requires pretty weird ordering on task notifications
I'd probably just upgrade to JUnit 5 and drop the old logic to report notifications for JUnit 4
If I were to look into JUnit 5 again I'd try to approach it like this

  • work with a clean branch off main
  • remove all the Java code from junit-interface, reuse same Scala code for JVM/JS/Native
  • refactor MUnitRunner to accept JUnit 5 APIs instead of JUnit 4 RunListener, this is where you might want to copy-paste stuff from my old branch

https://discord.com/channels/632642981228314653/671278431102697472/990954218657546240

@armanbilge
Copy link
Contributor

Part of the mystery is where @olafurpg's branch is, so we can use it as a copy-pasta source as suggested :)

@gabro
Copy link
Member

gabro commented Jul 17, 2022

I suppose it would be this one? olafurpg@50cd80a

@armanbilge
Copy link
Contributor

Aha, thanks!

@valencik valencik added the junit5 Relating to JUnit 5 Upgrade label Sep 29, 2022
@valencik valencik removed this from the MUnit v1.0 milestone Apr 25, 2023
@szymon-rd
Copy link

szymon-rd commented Jul 6, 2023

Is it a change requiring a release of a new major (per semver rules)?

@SimY4
Copy link

SimY4 commented Jul 6, 2023

IMO not necessarily if you provide JUnit4 and JUnit5 runner integrations in separate artefacts. ScalaTest has both JUnit4 and JUnit5 bindings (provided via external dependency: https://github.com/helmethair-co/scalatest-junit-runner)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle help wanted Extra attention is needed junit5 Relating to JUnit 5 Upgrade
Projects
None yet
Development

No branches or pull requests

7 participants