所以@Ignore注释很好地标记了一个测试用例不应该运行。
然而,有时我想忽略基于运行时信息的测试。例如,如果我有一个并发测试,需要在具有一定数量内核的机器上运行。如果这个测试是在一台单处理器机器上运行的,我认为仅仅通过测试是不正确的(因为它还没有运行),并且失败测试并破坏构建当然也不正确。
So I want to be able to ignore tests at runtime, as this seems like the right outcome (since the test framework will allow the build to pass but record that the tests weren't run). I'm fairly sure that the annotation won't give me this flexibility, and suspect that I'll need to manually create the test suite for the class in question. However, the documentation doesn't mention anything about this and looking through the API it's also not clear how this would be done programmatically (i.e. how do I programatically create an instance of Test or similar that is equivalent to that created by the @Ignore annotation?).
如果有人在过去做过类似的事情,或者有一个关于我如何做这件事的好主意,我很乐意听听。