Is there any * real solution for using multiple cores when running the JUnit / TestNG test suite?

I know that there is support for running JUnit or TestNG test suites in parallel, but this requires a certain configuration (for example, indicating the number of threads), and, most importantly, does not interfere with the race conditions in unsafe code.

Are there any tools for the JVM that transparently (i.e. without an explicit configuration) distribute separate tests to different CPU cores (using different threads in the same process or in different processes), while preventing race conditions regardless thread safety?

If such a tool does not exist, what would be the best approach to its implementation?

+3
source share
1 answer

My strong suggestion was to run your tests at the same time as the regular JUnit / TestNG tools.

The reason is simple: If the test failed because of the race condition, then the test did an excellent job - it revealed an error in your assumptions about the design, code or concurrency that you need to fix.

Anything that is not thread safe that is used by several test threads at the same time (for example, a mutable static singleton object that is used on a global basis) is probably a design flaw - you must either make it thread safe or initialize it separately each time as a local object .

0
source

Source: https://habr.com/ru/post/1785435/


All Articles