Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best methodology to test against multiple Java versions

I have multiple unit tests and component tests which I would like to test against several versions of Java (1.6, 1.7, 1.8, etc).

I wonder what’s the best methodology to it?

Should I run tests several times using Jenkins and each time I change the path of the JAVA_HOME variable to a different JRE?

Can I do using Maven plugin? Maybe different profiles?

In addition, is there a way using TestNG to exclude tests based on the JRE version? I can handle it using an if statement on a the java.version system property, however I wonder if there’s a more elegant way.

In case this will affect the answer, I would like to mention that looking forward I would like to test it against several OS types and multiple versions of the product (same tests against v1.0, v2.0, etc).

like image 715
nadavy Avatar asked Dec 16 '15 09:12

nadavy


People also ask

Can I run 2 versions of Java at the same time?

It is very possible to run multiple versions of Java on the same machine so you can run your existing applications and Ignition at the same time.

Can I install Java 8 and Java 11 together?

I know you can install both. Java 8 and Java 11 and keep them at the same time...

Can we have different JDK and JRE versions?

Coming to your Question; No it is not necessary to have both JDK and JRE of same version as we don't use both at the same time.

Can we have 2 Java versions in Windows?

It is absolutely possible to install side-by-side several JRE/JDK versions. Moreover, you don't have to do anything special for that to happen, as Sun is creating a different folder for each (under Program Files). There is no control panel to check which JRE works for each application.


1 Answers

To run the same code under different conditions jenkins can simply run the same scripts with different JAVA_HOME or other settings. Doing this on different triggers or as part of one multistage job is a decision for you

As for TestNG, see this answer How to disable testng test based on a condition

like image 120
Vorsprung Avatar answered Oct 24 '22 22:10

Vorsprung