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
Migrate from JUnit 4 to JUnit 5 #11839
base: main
Are you sure you want to change the base?
Conversation
Hi, @Nezisi! 👋 |
@ihostage Wouldn't mind porting later to AssertJ - though I strongly suggest doing it in a separate PR. A lot of the calls of Hamcrest / fest-assert are similar to those in AssertJ, but might have different meaning / behaviour. Getting a common ground by first migrating to JUnit 5, then doing the migration to AssertJ should be easier / less confusing. Haven't used AssertJ so far, but there is a script available from AssertJ doing a lot of the "grunt work": Just to clarify: The only reason I removed Hamcrest was because of its dormant state ( https://groups.google.com/g/hamcrest-dev/c/lYcF3lz8JDQ ) and fest-assert being dead. |
Last commit splits the play-test package into 3 separate projects:
I tried to set up the projects in build.sbt, but I think I need to add “somewhere” the java formatter, the code in the JUnit 5 tests is definitely wrongly formatted. Edit: lazy val userProjects needed to be extended, fixed. I just cannot find out where the java formatter configuration is sobs Regarding the JUnit5 extensions: I was first thinking about adding more complex extensions, for example an annotation-based approach like Given that the resources are already stretched thin, it's better to keep it as simple as possible. Imho the PR is now good to go. We just need to resurrect the jupiter-interface, but I've already got an PR open on that side. |
I've migrated the documentation, sorry it took so long. There is one part in the documentation validation that I cannot wrap my head around, sadly. Line 424 in 96cbace
The validation plugin seems to exclude explicitly everything that does not belong to either java / scala package structure. But this link exists and works: Where does the magic happen that the play-test package gets moved to java/play/test... Sorry if I'm missing something obvious here. :( Edit: It was a problem related to SBT. I corrupted the cache, which led to a lot of confusion. Nuking all target directories after I noticed the CI did what I actually expected to happen, everything was fine. |
documentation/manual/working/javaGuide/main/tests/JavaFunctionalTest.md
Outdated
Show resolved
Hide resolved
… junit5 test runner
… controllers package vs controller dir
… only in JUnit 4)
…ter -> After*Each*, not all)
At long last, this should cover all the necessary grunt work to be on JUnit 5. There is a lot of room for improvement, for example the suggestion of @ihostage to use AssertJ, additional usage of extensions / improvement for the extensions, removal of deprecations inside the test, ... But that should come – in my opinion – after merging this PR. ;) Given the massive size, it's better to get this merged before it turns into an endless “yet another improvement” limbo. |
This is a PR that converts the JUnit 4 + Hamcrest + fest-assert Java code to JUnit 5.
I tried to minimize the changes to the bare minimum as good as I could, thus:
I'm not entirely sure what the best approach regarding dependencies is: I'd guess it's best to add JUnit 4 dependencies only to the play-test project?