简体   繁体   中英

Is it possible to run integration tests in parallel (Spring boot)?

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?

I found the answer to my question here

2.19. Parallel Execution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM