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

refactor: migrates from JUnit 4 to JUnit 5 (Jupiter) #222

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

codefromthecrypt
Copy link
Member

This migrates from JUnit 4 to JUnit 5 (Jupiter) beginning with the following OpenRewrite command:

$ ./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:LATEST \
  -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration

After this, we had to do some work, notably as Brave needs to support non-alpha versions of OkHttp and alpha 5 creates a classpath conflict on Okio. Notably, I had to revert changes for the okhttp and urlconnection senders, which formerly used normal mockwebserver 3 and were automatically migrated to v5 alpha.

Next, I had to polish formatting as it undid some of that, and also fixed some cases where we were inconsistent. Then, I reviewed our base pom and removed some special cases that were no longer needed. Finally, I swept through and reduced visibility modifiers where possible.

Note: Both testcontainers and mockwebserver v3 have an implicit dep on junit 4. This is ok and the same as zipkin. The main thing here is we aren't explicitly using it anymore.

This migrates from JUnit 4 to JUnit 5 (Jupiter) beginning with the
following OpenRewrite command:

```bash
$ ./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:LATEST \
  -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration
```

After this, we had to do some work, notably as Brave needs to support
non-alpha versions of OkHttp and alpha 5 creates a classpath conflict on
Okio. Notably, I had to revert changes for the okhttp and urlconnection
senders, which formerly used normal mockwebserver 3 and were
automatically migrated to v5 alpha.

Next, I had to polish formatting as it undid some of that, and also
fixed some cases where we were inconsistent. Then, I reviewed our base
pom and removed some special cases that were no longer needed. Finally,
I swept through and reduced visibility modifiers where possible.

Note: Both testcontainers and mockwebserver v3 have an implicit dep on
junit 4. This is ok and the same as zipkin. The main thing here is we
aren't explicitly using it anymore.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt
Copy link
Member Author

cc @timtebeek I think this particular OpenRewrite migration will also be rough in the other projects for reasons above, but yeah still helpful and hopefully paves a path for cleaner refactors later.

@@ -120,11 +120,6 @@
https://github.com/charithe/kafka-junit -->
<version>4.2.10</version>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note we have kafka-junit here in the benchmark project, but probably we can migrate that to testcontainers at a low priority

@codefromthecrypt codefromthecrypt merged commit 963caa4 into master Dec 14, 2023
2 checks passed
@codefromthecrypt codefromthecrypt deleted the jupiter branch December 14, 2023 02:55
@codefromthecrypt
Copy link
Member Author

thanks for letting me interrupt you yet another day in a row @anuraaga!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants