Is there a way to distribute unit tests so that they all run faster?

Our JUnits are designed for 6 hours of work. Is there an easy way to run 1 / n of them on n different machines?

+6
unit-testing junit
source share
3 answers

GridGain (a free cloud implementation) can distribute JUnit tests passing through a cluster of nodes. See the JUnit Distributed Overview .

Just in case, this is not quite what you are asking for, but TestNG can run tests in parallel (this will already make your build faster). See Advanced Parallel Testing with TestNG and Data Providers .

see also

+2
source share

It’s just one option from my head - to use TeamCity and have different build scripts that know how you want to break the tests and install them as separate projects (each section), and then configure n agents, which can be done using Amazon EC2, which allows large values ​​of n.

Since you probably want more than three agents, you do not fall into your free territory.

Some assumptions: there is no common database that links all these tests together, and all tests can work independently of each other.

If there is a common database, this makes things much more complicated, since you will need a database for each agent so that the tests do not attack each other (and, of course, computing power for EC2 would probably be impractical).

0
source share

I have proven a concept¹ that demonstrates how to distribute tests using docker and maven.

You can use the surefire plugin JVM parameter to run the JVM in the docker container, and not to use it directly on the host system. In addition, you need to somehow provide the file system of the test project and the .m2 repository in the docker container.

[1] https://github.com/Jotschi/swarmfire

0
source share

All Articles