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).
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.
I know you can install both. Java 8 and Java 11 and keep them at the same time...
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With