jakartaee / platform-tck

Jakartaee-tck
Other
123 stars 103 forks source link

Add example of using OpenRewrite to refactor TCK tests. #1141

Open scottmarlow opened 1 year ago

scottmarlow commented 1 year ago

Figure out the OpenRewrite tasks. Something like:

cc @gurunrao

scottmarlow commented 1 year ago

If https://github.com/eclipse-ee4j/jakartaee-tck/issues/1143 analyzes the EE 10 dist folder contents and maps that to Shrinkwrap API calls for each test, we still need to remap each test to Junit which needs to be done for this issue.

timtebeek commented 7 months ago

This LinkedIn post brought me here; is there anything I can help with? For context: I work on OpenRewrite at Moderne, but know next to nothing about Jakarta EE or the TCK tests here, so would need some help better understanding the challenge with before/after examples. Happy to help where I can past that, and already trying to make the TCK projects available through https://app.moderne.io for faster and exploratory recipe runs.

timtebeek commented 7 months ago

It's now possible to select the Jakarta EE organization group from the Moderne platform, and run recipes there to quickly see results. Here's an example run to adopt the diamond operator: https://app.moderne.io/results/fko6pCVmp , but any of the 1200 recips there should work as well. From here I'll work to support more TCK projects, such that those can be targeted as well.

scottmarlow commented 2 months ago

Some work in progress with refactoring Jakarta EE Platform TCK tests:

https://github.com/scottmarlow/jakartaee-tck/blob/rewritejpa/jpa/pom.xml has some changes for refactoring the JPA/Peristence tests.

https://github.com/scottmarlow/jakartaee-tck-tools/blob/rewritejpa/tools/tck-rewrite/src/main/java/tck/jakarta/platform/rewrite/AddArquillianDeployMethodRecipe.java + https://github.com/scottmarlow/jakartaee-tck-tools/blob/rewritejpa has some changes as well. Work in progress.

We have a Jakarta-ee-tck channel on the OpenRewrite slack https://rewriteoss.slack.com/archives/C070UMPTE1Z for discussions as well.

scottmarlow commented 1 month ago

From https://rewriteoss.slack.com/archives/C070UMPTE1Z/p1714744233792969?thread_ts=1714673309.378089&cid=C070UMPTE1Z:

Tim te Beek 30 minutes ago we do recommend that you try not to do everything in a single recipe or visitor, but instead break up the changes into smaller steps that can be verified and tested individually

Tim te Beek 30 minutes ago ideally some (or most) of those changes can be achieved with declarative yaml recipes, for common stuff like adding dependencies, changing packages, classes and method names

Tim te Beek 29 minutes ago then beyond that supplement with custom visitors as needed, ideally covered by unit tests, as our testing framework helps uncover and flush out a lot of potential issues that you'd otherwise get at runtime

scottmarlow commented 1 month ago

https://github.com/scottmarlow/jakartaee-tck-tools/tree/rewritejpa/tools/tck-rewrite + https://github.com/scottmarlow/jakartaee-tck-tools/tree/rewritejpa/tools/jar2shrinkwrap has updates to work with https://github.com/scottmarlow/jakartaee-tck/tree/rewritejpa such that doing a mvn -Djar2shrinkwrap.technology=jpa org.openrewrite.maven:rewrite-maven-plugin:runNoFork will update a subset of JPA tests to generate ShrinkWrap/Arquillian code based on how the EE 10 Platform TCK binary tests were packaged.

The refactoring doesn't yet deal with the test vehicles but will start to do that soon for the JPA tests.

scottmarlow commented 1 month ago

Thanks again to @timtebeek for helping us to get our OpenRewrite recipe working for the ^ example. We have much work to do and many challenges but I think we should soon have our initial example ready to check in.

timtebeek commented 1 month ago

Great to hear! Let me know when the changes land and I'll see if we can speed up recipe authoring and running with the tools we have available at Moderne. Nice to see this come together.