6

Already has a test environment configured for a specific application (several dozen test classes).

TestContainers are also used here.

I see such an algorithm:

  1. The Application context is raised once, for the entire time of working with tests.
  2. Also raises one container with Postgresql.
  3. Since it is impossible to follow the order of integration tests, so each test will clean up after itself the data that was written to the database.
  4. Find out from the JVM how many processor cores are allocated to it and create a capacity for the thread pool based on this number.
  5. Create a thread pool in the class with Application context (Executors....) and issue tasks for running test classes for the threads.
  • Is it possible to control the launch of test classes, that is, how to do it from the code ?
  1. To run multiple threads simultaneously (according to the number of cores in the current system) we can use CyclicBarrier.
  2. Or you can use a different approach:

Again, you need to know how to run all the test methods of this class from an object of the class, with test methods.

So, we create objects of test classes, and using the Stream API, then call the parallel() method (but here I do not control the number of simultaneously running threads).

What are the options for solving this problem ?

Who has any ideas ?

3
  • Hmm, TestContainers already has Junit integration + Gradle/Maven can execute your Junit tests concurrently. Jan 5, 2021 at 13:31
  • Explain in more detail. So it runs multiple integration test threads at the same time ? And does it do this based on the specific number of processor cores allocated to the JVM ?
    – skyho
    Jan 5, 2021 at 16:19
  • By default, Gradle execute only one test at a moment. If you want, Gradle can use the number which you want (May use number of processor cores). I think with maven is the same thing. Jan 6, 2021 at 9:21

1 Answer 1

5

I found the answer to my question here

2.19. Parallel Execution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.