Add Testcontainers 1.x to 2.x migration rules#21
Merged
Conversation
…erComposeContainer and getContainerIpAddress
…nforce explicit image versions
wakingrufus
reviewed
Dec 9, 2025
| } | ||
|
|
||
| try { | ||
| Class.forName(newPackageName + "." + simpleName); |
Member
There was a problem hiding this comment.
I dont think this is safe because the classpath where we evaluate rules is not the same as the runtime classpath of the code we are checking
Member
Author
There was a problem hiding this comment.
addressed this by detecting if the container class is deprecated or not
wakingrufus
reviewed
Dec 9, 2025
| */ | ||
| private static final Map<String, String> OVERRIDES = new HashMap<>(); | ||
|
|
||
| static { |
Member
There was a problem hiding this comment.
instead of static, I think ideally this should be a lazy singleton, just to prevent running this when the rule is not selected
…der to avoid loading things one very execution even when the rule is not used
emilyyuan03
approved these changes
Dec 9, 2025
| } | ||
|
|
||
| // Test classes using 1.x patterns | ||
| @SuppressWarnings("unused") |
Contributor
There was a problem hiding this comment.
I like the SuppressWarnings! (we should add it to the other test cases)
wakingrufus
approved these changes
Dec 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds architecture rules to help teams migrate from Testcontainers 1.x to 2.x by detecting breaking changes before upgrading and deprecated patterns after upgrading.
Testcontainers 2.x introduced several breaking changes that will cause compilation errors:
DockerComposeContainerrenamed toComposeContainergetContainerIpAddress()replaced withgetHost()What's Added
Pre-Upgrade Rules (
Testcontainers1xRule)Run these before upgrading to find patterns that will break:
dockerComposeContainerRule (MEDIUM) - Detects
DockerComposeContainerusagecontainerIpAddressMethodRule (MEDIUM) - Detects
getContainerIpAddress()callsnoArgConstructorRule (MEDIUM) - Detects no-arg constructors
Post-Upgrade Rules (
Testcontainers2xRule)Run these after upgrading to clean up deprecated patterns:
Big remaining question
Should this be in the testing-frameworks module? or in a new one?