Skip to content

Instantly share code, notes, and snippets.

@sormuras
Last active July 1, 2024 10:57
Show Gist options
  • Save sormuras/547db4efff6d713f984213fc92a75f5e to your computer and use it in GitHub Desktop.
Save sormuras/547db4efff6d713f984213fc92a75f5e to your computer and use it in GitHub Desktop.
TestNG-JUnit-Migration Guide

jdk-junit-migration

Get sources of JDK

  • Fork openjdk/jdk
  • Clone my/jdk into jdk/
  • Check that jdk/test/jdk/TEST.ROOT exists

Get JTREG binaries

  • Either compile sources from openjdk/jtreg or grab package jtreg-7.4+1.zip from https://builds.shipilev.net/jtreg/
  • Unzip it into jtreg/
  • Check that jtreg/lib/jtreg.jar exists

Create test file

Use adopted and absolute paths below.

-jar
/path/to/jtreg/lib/jtreg.jar
-agentvm
-w:tmp/work
-r:tmp/results

Run test

java @test jdk/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java

Get ErrorProne With Dependencies

Get TestNG-JUnit-Migrator

Create javac.args file

Use adopted and absolute paths below.

-XDaccessInternalAPI
-XDcompilePolicy=simple
-processorpath /path/to/lib/error_prone_core-2.27.1-with-dependencies.jar:/path/to/lib/testng-junit-migrator...jar
'-Xplugin:ErrorProne -XepPatchChecks:TestNGJUnitMigration -XepPatchLocation:IN_PLACE'

Create migrate file

Use adopted and absolute paths below.

-javacoption:@/path/to/javac.args

Run migration

java @test @migrate jdk/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java

Cleanup

Finish and cleanup migration in PatchTest.java until test is happy again:

java @test jdk/test/jdk/tools/launcher/modules/patch/basic/PatchTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment