I have in my project a lot of unit tests, written in JUnit and TestNG. The building process is based on maven with surefire plugin.
Is there any way/plugin for maven to
In maven surefire, you can use forkedProcessTimeoutInSeconds, along with forkMode=once.
forkMode=once
This will kill the forked jvm if it takes too long. If you want to do this per test, you can forkMode=pertest or forkMode=always (which does it for each class).