Skip to content

StephenSeltzer/convert-junit4-to-junit5

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a project I wrote for myself to facilitate migrating a good number of tests to JUnit 5 syntax. Feel free to use it/enhance it/etc if you find it useful.

Pre-reqs

Before starting out, the program assumes you have:

  • Updated your Maven POM/Groovy build file/whatever to reference the new JUnit 5 jars
  • Migrated off JUnit 3.8. This program assumes you are on JUnit 4. JUnit 3.8 code will continue to work in JUnit 5. (as will JUnit 4 code.) But the goal of this program is to migrate JUnit 4 syntax to JUnit 5 syntax.

Running the program

Pass the absolute path of the directory containing your tests (ex /my/dir/src/test/java) when running class jb.Updater. The program outputs the name of each file as it goes through them. It runs quickly. Under a few seconds for two thousand files. Then make manual edits at end (or rollback those test classes and deal with them later). In particular the following will not compile after running the program and require manually migration.

  1. Parameterized tests
  2. Tests that use expected parameter
  3. Tests that use timeout parameter

Side effects

This program updates every class and reformats your code. This is a side effect of using Java Parser. If you have a standard coding format, you can always reapply it after running. Regardless, make sure to commit your code before running the program so this commit only has the refactoring to JUnit 5.

Other notes

  • The program can be run multiple times. That way you can rollback the classes that require manual intervention and commit the others. Then later when you re-run, it will only update the remaining classes.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%