how can I spread surefire junit tests across different compute resources - maven

I'd like to spread the execution of junit tests across different systems, when maven surefire is running the tests. Is this possible?
There are ~ 20,000 junit tests, and when running 5 in parallel (forks), it takes approximately 40 minutes. Running more in parallel starts to hit resource problems. If I could run half of the tests classes on a different VM (or something like kubernetes, etc), then that could cut the execution time in half.
Is this possible?

Related

Liquibase slows down unit tests

Our project has over 500 test suites. It takes up to 30 mins to run and I found a huge amount of time spending is on Liquibase when initializing Spring context for test suite.
Would like to know if there are any good approach to accelerate the process? E.g. Run Liquibase one time and do file copy (h2 database) to reset database for each test suite?

How to run forked JUnit tests in optimal order?

I have some long running JUnit tests which I want to run first to avoid them being queued and executed last and thus delaying the whole test execution process.
I currently use maven surefire to run my tests using:
forkCount: 5
reuseForks: false
Is there a way to specify which tests should be run first? Or a way to optimize the order in which the tests are run?
The runOrder=balanced parameter does not seem to work in combination with forkCount > 0 and reuseForks false.
Unfortunately, you can’t determine the test execution order. Here is a clumsy workaround for this problem. For integration tests, I use a JUnit extension to run tests in specific order.

JUnit and Spring - code coverage % is wrong when using multiple Threads in test

We tried to use a couple of code-coverage plugins for our spring project (EclEmma,Clover).
Both are providing wrong results regarding the coverage %.
The tests are using Spring's taskExecutor (thread pool).
All the code that the task executors threads executes does not count as covered.
Any ideas why?

Spock - Do not run Specs simultaneously

I'm running functional tests using Spock where the tests manipulate the database, and the Specs can conflict with each other if run simultaneously. From my web debugger, it appears that when I run gradle test that the calls to the web service from different Specs are being called simultaneously. The Specs themselves are being called with the #Stepwise annotation, and the tests are run in the correct order. How can I have Specs run separately in some order? They do not need to run in any specific order.

Is there some settings in Maven or Bamboo to restrict the tests to run in the same JVM as Bamboo rather than running in a seperate JVM?

I use Bamboo and Maven for continuous integration and running tests. Where ever scheduled/dependent maven tests run in Bamboo, it creates a new JVM. I have a huge no. of test for each project configured in Bamboo. There are as many as 20 projects, all have tests specific to them. So JVM number also increases, that makes the server less responsive, since multiple JVM increases the memory footprint.
Is there any settings in Maven or Bamboo to restrict the tests to run in the same JVM as Bamboo rather than running in a separate JVM?
You can set this in Maven surefire-plugin:
http://maven.apache.org/plugins/maven-surefire-plugin/examples/forking.html
You have the following choices:
forkMode=never
forkMode=once
forkMode=always

Resources