Add a new test method, ignoreMethodTest, to TestRunnerTest. It will go up against a new test class, IgnoreMethodTest, which contains three methods marked with @TestMethod. One of the test methods (testC) is additionally marked @Ignore. You must verify that this test method is not executed. package sis.testing; import java.util.*; import java.lang.reflect.*; public class TestRunnerTest { private TestRunner runner; // ... @TestMethod public void ignoreMethodTest() { runTests(IgnoreMethodTest.class); verifyTests(methodNameA, methodNameB); } // ... } // ... class IgnoreMethodTest { @TestMethod public void testA() {} @TestMethod public void testB() {} @Ignore @TestMethod public void testC() {} } The @Ignore annotation declaration looks a lot like the @TestMethod declaration. package sis.testing; import java.lang.annotation.*; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Ignore {} To get your tests to pass, make the following modification to TestRunner. package sis.testing; import java.util.*; import java.lang.reflect.*; class TestRunner { ... private void loadTestMethods() { testMethods = new HashSet<Method>(); for (Method method: testClass.getDeclaredMethods()) if (method.isAnnotationPresent(TestMethod.class) && !method.isAnnotationPresent(Ignore.class)) testMethods.add(method); } ... } |