@TestMethod public void ignoreWithDefaultReason() { runTests(DefaultIgnoreMethodTest.class); verifyTests(methodNameA, methodNameB); Map<Method, Ignore> ignoredMethods = runner.getIgnoredMethods(); Map.Entry<Method, Ignore> entry = getSoleEntry(ignoredMethods); Ignore ignore = entry.getValue(); assert TestRunner.DEFAULT_IGNORE_REASON. equals(ignore.reasons()[0]); } class DefaultIgnoreMethodTest { @TestMethod public void testA() {} @TestMethod public void testB() {} @Ignore(initials=TestRunnerTest.IGNORE_INITIALS) @TestMethod public void testC() {} } You will need to define the constant DEFAULT_IGNORE_REASON in the TestRunner class to be whatever string you desire: class TestRunner { public static final String DEFAULT_IGNORE_REASON = "temporarily commenting out"; // ... You can supply a default value on any annotation type member. The default must be a constant at compile time. The new definition of @Ignore includes a default value on the reasons member. Note use of the keyword default to separate the member signature from the default value. package sis.testing; import java.lang.annotation.*; @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Ignore { String[] reasons() default TestRunner.DEFAULT_IGNORE_REASON; String initials(); } |