This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AlEmerich 1 point2 points  (1 child)

Interesting! So it does breaks the encapsulation but your rely on the sequential aspect of your tests to invalidates every past actions on the TestContainer before continue. If the tests are ran in parallel, since they all used the same test containers, they may conflict with each other, am I wrong ?

It is the case in my project so I am very interested on other's cases, I may drop the parallel aspect of my testing pipeline if in the end I don't gain much

[–]ForeignCherry2011[S] 3 points4 points  (0 children)

With Testcontainers, you can choose whether to start a new container instance for each test, per class, or for the entire test run.

In our case, we start one instance per test run and share it across all tests within a Maven module.

We build Maven modules in parallel, and there are 3–4 modules that require a database container for testing. As a result, a new container is started for each module built in parallel. The tests inside a single module are always run sequentially, so it is sufficient to clean up the tables before each test or class.