Class ExcludableTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by ExcludableTestCase
All Implemented Interfaces:
Test

public abstract class ExcludableTestCase
extends TestCase

Test case that can be exluded from a test run using system properties. This is especially useful for known issues or similar test cases that are expected to fail, but should not flag the entire test run as a failure.

This class overrides the runBare() method to check whether the test should or should not be run. This decision is based on the junit.excludes and junit.includes system properties. If defined, these properties are interpreted as whitespace-separated sets of test identifiers to exclude or include. Normally each test is included in the test run, but identifying a test in junit.excludes will exclude that test. The exclusion can be overridden by identifying the test in junit.includes which again overrides the exclusion.

Each test is identified by a set of test identifiers. The default identifiers of a test are:

The set of identifiers of a test can be extended using the addIdentifier(String) method. A common use case for this would be for example to include the issue tracker identifier for the known issue for which the test case was written.


Constructor Summary
ExcludableTestCase()
          Creates an excludable test case without a name.
ExcludableTestCase(String name)
          Creates an excludable test case with the given name.
 
Method Summary
 void addIdentifier(String identifier)
          Adds an identifier to this test.
 void runBare()
          Runs the bare test sequence unless the test has been excluded.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExcludableTestCase

public ExcludableTestCase()
Creates an excludable test case without a name.


ExcludableTestCase

public ExcludableTestCase(String name)
Creates an excludable test case with the given name.

Parameters:
name - test name
Method Detail

addIdentifier

public final void addIdentifier(String identifier)
Adds an identifier to this test.

Parameters:
identifier - test identifier

runBare

public final void runBare()
                   throws Throwable
Runs the bare test sequence unless the test has been excluded. Determines the exclusion by comparing the set of test identifiers to the contents of the junit.excludes and junit.includes system properties. If the test is not excluded, then the standard TestCase.runBare() method is invoked.

Overrides:
runBare in class TestCase
Throws:
Throwable - if any exception is thrown by the test