Issue
is there a way to specify the JVM version in a junit test, when multiple java types are available on an OS ?
I'd like to do something like this:
@JVM=1.5
public void test1(){
run();
}
@JVM=1.7
public void test2(){
run();
}
etc..
Solution
No, you'll have to run the JUnit tests multiple times with multiple VMs. You can then use Assume to only run the tests for the correct VM:
public void test1(){
// not compiled or tested
Assume.assumeThat(System.getProperty("java.version"), CoreMatchers.startsWith("1.5"));
run();
}
public void test2(){
Assume.assumeThat(System.getProperty("java.version"), CoreMatchers.startsWith("1.7"));
run();
}
Please note that I haven't compiled this, so there may be errors. Then, in your build tool, run these tests twice in two different VMs.
Answered By - Matthew Farwell
Answer Checked By - Terry (JavaFixing Volunteer)