Do not ever exclude junit if Testcontainers is used #746
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
Instead of adding the JUnit 4 exclusion to all dependencies and then removing it from specific ones that depend on Testcontainers, just don’t add the exclusion when Testcontainers is used.
What's your motivation?
We have implemented some test libraries that (transitively) depend on Testcontainers. When (indirectly) running the JUnit 5 migration recipe, it always adds the junit exclusion on those, which breaks the build. This forces us to un-exclude JUnit 4 as a followup recipe.
Have you considered any alternatives or workarounds?
Current workaround is to remove the exclusion explicitly for all dependencies after JUnit 5 migration:
Any additional context
This makes the recipe more conservative. If a project transitively depends on Testcontainers, it won’t add the exclusion to dependencies that do not depend on Testcontainers (but still depend on JUnit 4) but that’s ok since exclusions have to be added everywhere to work properly.
This provides a more generic solution to #429 and #477.
Checklist