All- There is hardly a time when you want to completely comment out or disable test case(s) using something like *JUnit's* @Ignore annotation <https://github.com/junit-team/junit/wiki/Ignoring-tests> [0]. This is not a practice that should be encouraged since tests in a suite is money in the bank.
I do think there are occasional times when a test (e.g. integration, end-to-end test) must be temporarily disabled because it might interfere with the proper functioning of tests down stream, causing seemingly random failures or test hangs. Though, one could certainly argue that there are probably some test code smells and improper test setup/tearDown lurking. Never-the-less, it may (sometimes) be appropriate to disable a test rather than simply @Ignoring the test completely and subsequently forgetting to address the disabled test issues later, so, as part of a TDD talk <http://www.slideshare.net/john_blum/testdriven-development-49565217> [1] I gave, I created a Java Annotation to "conditionally" ignore tests, with @ConditionalIgnore <https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/main/java/org/tdd/junit/ConditionalIgnore.java> [2] annotation an accompanying *JUnit 4* Rule <https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/main/java/org/tdd/junit/rules/ConditionalIgnoreRule.java> [3] to process the test case method-level annotation. See the @IgnoringTestCasesExamplesTest <https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/test/java/org/tdd/example/junit/IgnoringTestCasesExampleTest.java> [4] on how a developer may use this in practice. Essentially, a developer would.. @Test @ConditionalIgnore(value = "description as to why the test is ignored", until="using DateFormat pattern yyyy-MM-dd") public void someTestCase() { ... } Optionally, a developer can define a more complex condition by implementing the IgnoreCondition interface <https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/main/java/org/tdd/junit/IgnoreCondition.java> [5], then... @Test @ConditionalIgnore(value = "description as to why the test is ignored", condition=MyComplexIgnoreCondition.class) public void someTestCase() { ... } It is also worth noting that @ConditionalIgnore might be more useful as a test annotation for "ignoring" tests that require a special context, or environment, in which to run. Therefore, tests could be conditionally ignored based on the fact they were written for Windows with the availability of a certain driver. This is synonymous with using *JUnit's* Assumptions <https://github.com/junit-team/junit/wiki/Assumptions-with-assume> [6], however, using the IgnoreCondition interface allows a developer to define more complex set of criteria. Internally, the *JUnit* Assumption infrastructure is exactly what @ConditionalIgnore and ConditionalIgnoreRule leverage. Again, I have filed another JIRA (GEODE-167 <https://issues.apache.org/jira/browse/GEODE-167> [7]) for review and inclusion into *Apache Geode's* codebase if the community deems necessary or worthy. Cheers, -- -John [0] - https://github.com/junit-team/junit/wiki/Ignoring-tests [1] - http://www.slideshare.net/john_blum/testdriven-development-49565217 [2] - https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/main/java/org/tdd/junit/ConditionalIgnore.java [3] - https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/main/java/org/tdd/junit/rules/ConditionalIgnoreRule.java [4] - https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/test/java/org/tdd/example/junit/IgnoringTestCasesExampleTest.java [5] - https://github.com/codeprimate-software/test-driven-development/blob/master/unit-testing/src/main/java/org/tdd/junit/IgnoreCondition.java [6] - https://github.com/junit-team/junit/wiki/Assumptions-with-assume [7] - https://issues.apache.org/jira/browse/GEODE-167
