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

Testcontainers best practices recipes #438

Open
9 tasks
timtebeek opened this issue Dec 5, 2023 · 1 comment
Open
9 tasks

Testcontainers best practices recipes #438

timtebeek opened this issue Dec 5, 2023 · 1 comment
Labels

Comments

@timtebeek
Copy link
Contributor

Based on this nice article from @sivaprasadreddy
https://www.atomicjar.com/2023/11/testcontainers-best-practices/

What problem are you trying to solve?

Automate some of the best practices for testcontainers, such that users can adopt these with little effort, unlocking a move to testcontainers cloud in some areas.

  • Don’t rely on fixed ports for tests
  • Don’t hardcode the hostname
  • Don’t hardcode the container name
  • Copy files into containers instead of mounting them
  • Use the same container versions as in production
  • Use proper container lifecycle strategy
  • Leverage your framework’s integration for Testcontainers
  • User preconfigured technology-specific modules when possible
  • Use WaitStrategies to check the container is ready

Any additional context

In part also discussed on

@timtebeek
Copy link
Contributor Author

For context: we already have some recipes in this module; my suggestion is to expand the recipe coverage with the above.

type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.testcontainers.TestContainersBestPractices
displayName: Testcontainers best practices
description: Apply best practices to Testcontainers usage.
recipeList:
# Upgrade to latest version of Testcontainers
- org.openrewrite.java.dependencies.UpgradeDependencyVersion:
groupId: org.testcontainers
artifactId: "*"
newVersion: 1.19.x
- org.openrewrite.java.testing.testcontainers.ExplicitContainerImages
- org.openrewrite.java.testing.testcontainers.GetHostMigration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Recipes Wanted
Development

No branches or pull requests

1 participant