Zim-Zam O'Pootertoot Zim-Zam O'Pootertoot - 1 year ago 68
Java Question

Automatically chaining multiple tests on broken JVMs

I am running a series of performance tests from a linux command line using maven + testng on Java8.

Most of these tests run until they break the JVM (typically by running out of memory) at which point I manually set up and run another test from a new JVM.

I would like to be able to automatically chain multiple tests to run back to back, but I don't know of a way to accomplish this when the previous test leaves the JVM in an unusable state.

Is there a way for me to reset a broken JVM (or something along those lines) via Java / Maven / Linux / some other program / framework?

I have access to either Oracle's JDK or to OpenJDK, but if need be I may be able to convince the server admin to install another JDK.

Answer Source

The maven-surefire-plugin allows tests to be run in a forked JVM. The information is on the plugin page, but you'll need something like:


That will create a new JVM for each test run. You can tweak this by changing the forkCount (for example, to ensure tests don't run in parallel or do) and use the reuseForks to determine whether the JVMs should be recycled.