从 Eclipse 中的 JUnit 测试 运行 检测 Eclipse 版本

Detect Eclipse version from JUnit test running in Eclipse

我是 运行 在 Eclipse 中使用 JavaJUnit 开发的一系列系统测试,使用 Eclipse 控制台作为输出。我计划使用一些控制台字符为某些测试实现更好的控制台输出,这些字符在 Eclipse Mars (https://bugs.eclipse.org/bugs/show_bug.cgi?id=76936) 之前不受支持。

为了确保与同事 运行 旧版本 Eclipse 的兼容性,我需要 以编程方式检测 JUnit 测试中的 Eclipse 版本.这可能吗?如果可能,怎么做?

System.getProperty("eclipse.buildId");

将为您提供 Eclipse 构建 ID,类似于

4.4.2.M20150204-1700

可以通过Java属性获取:

System.getProperty("eclipse.buildId").