0
A
回答
4
System.getProperty("os.name")
会给你操作系统的名称。然后,您可以使用Assume
类跳过一个测试,如果操作系统是Windows:
@Test
public void testSomething() {
Assume.assumeFalse
(System.getProperty("os.name").toLowerCase().startsWith("win"));
// test logic
}
2
您还可以使用@Before
绕过包含在类的所有测试:
@Before
public void beforeMethod()
{
Assume.assumeFalse(System.getProperty("os.name").toLowerCase().startsWith("win"));
// rest of the setup
}
相关问题
- 1. 只执行JUnit测试的Ant任务不会运行测试
- 2. Linux上的IntelliJ JUnit测试运行器和Gradle JUnit测试运行器之间的差异
- 3. 并行运行JUnit测试
- 4. JUnit MethodRule只测试一行
- 5. 对上下文运行jUnit测试
- 6. 类运行JUnit测试
- 7. JUnit:运行同时测试
- 8. 运行JUnit测试硒
- 9. 运行Android的JUnit测试
- 10. 运行常规测试在Linux上
- 11. 从另一个JUnit测试类运行JUnit测试类
- 12. 使测试数据库上运行Spring JUnit测试
- 13. 如何在Ant中只运行特定的JUnit测试?
- 14. ClassNotFoundException:在Eclipse中运行JUnit测试
- 15. JUnit在JAR中运行测试
- 16. 在Hudson通过JUnit运行硒测试
- 17. 如何在SCons下运行JUnit测试?
- 18. 无法在Eclipse中运行junit测试
- 19. 在GWTTestCase中运行当前Junit测试
- 20. 列出正在运行的jUnit测试
- 21. 运行JUnit测试套件在Eclipse
- 22. 在系列中运行IntelliJ JUnit测试
- 23. 在终端运行JUnit测试
- 24. 不能运行调试robotium junit测试
- 25. Junit测试在包上运行失败,但在文件上运行时成功
- 26. 在多台远程机器上运行并行junit测试
- 27. 在套件级别上并行运行JUnit测试?
- 28. junit测试可以并行运行吗?
- 29. 可以并行运行Junit测试吗?
- 30. 与Junit并行运行测试
“可我得到的OS来自Java的平台?“在提问之前做一些研究怎么样? – Plux 2014-10-17 14:41:51
请参阅[如何提问](http://stackoverflow.com/help/how-to-ask)“搜索和研究 ...并跟踪您发现的内容即使您没有找到网站上其他地方的有用答案,包括未提供帮助的相关问题的链接可以帮助他人理解您的问题与其他问题的区别。“”解释您是如何遇到您要解决的问题的,**和**任何**困难都阻止你自己解决**。“ – 2014-10-17 15:06:54