Regarding the "is IDEA the test initiator" question, the answer is rather simple:
public static boolean isIdeaRunningTheTest() {
try {
final Class<?> aClass = Class.forName("com.intellij.rt.execution.junit.JUnitStarter");
} catch (ClassNotFoundException e) {
return false;
}
return true;
}
As of determining the IDEA version...
The following works as long as the installation directory follows the standard from the setup program (on windows, I don't know where it's installed on Mac or Linux systems).
public static String getIdeaVersionTheDumbWay() {
String result="unknown";
final String binPath = System.getProperty("idea.launcher.bin.path");
if (binPath.contains("IntelliJ IDEA")) {
final String[] strings = binPath.split(System.getProperty("file.separator")+System.getProperty("file.separator"));
for (String s : strings) {
final int startIndex = s.indexOf("IntelliJ IDEA");
if (startIndex >= 0) {
result= s.substring(startIndex + 14);
}
}
}
return result;
}