/** * Construct a new {@code SpringRepeat} statement for the supplied * {@code testMethod}, retrieving the configured repeat count from the * {@code @Repeat} annotation on the supplied method. * @param next the next {@code Statement} in the execution chain * @param testMethod the current test method * @see TestAnnotationUtils#getRepeatCount(Method) */ public SpringRepeat(Statement next, Method testMethod) { this(next, testMethod, TestAnnotationUtils.getRepeatCount(testMethod)); }
/** * Construct a new {@code SpringFailOnTimeout} statement for the supplied * {@code testMethod}, retrieving the configured timeout from the * {@code @Timed} annotation on the supplied method. * @param next the next {@code Statement} in the execution chain * @param testMethod the current test method * @see TestAnnotationUtils#getTimeout(Method) */ public SpringFailOnTimeout(Statement next, Method testMethod) { this(next, TestAnnotationUtils.getTimeout(testMethod)); }
@DirtiesContext public static class ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase extends BaseTestCase { @Test public void verifyContextWasAutowired() { assertApplicationContextWasAutowired(); } }
@Rollback(false) static class ClassLevelRollbackWithExplicitValueTestCase { public void test() { } }
@Commit static class ClassLevelRollbackViaMetaAnnotationTestCase { public void test() { } }
@SuppressWarnings("unused") @IfProfileValue(name = NAME, value = VALUE + "X") private static class DisabledAnnotatedSingleValue { public void nonAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
@SuppressWarnings("unused") @MetaEnabled private static class MetaEnabledAnnotatedSingleValue { public void nonAnnotatedMethod() { } @MetaEnabled public void enabledAnnotatedMethod() { } @MetaDisabled public void disabledAnnotatedMethod() { } }
@SuppressWarnings("unused") @MetaDisabled private static class MetaDisabledAnnotatedSingleValue { public void nonAnnotatedMethod() { } @MetaEnabled public void enabledAnnotatedMethod() { } @MetaDisabled public void disabledAnnotatedMethod() { } }
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD) static class DirtiesContextDeclaredLocallyBeforeEachTestMethod { void clean() { /* no-op */ } }
@SuppressWarnings("unused") @IfProfileValue(name = NAME, values = { "foo", VALUE, "bar" }) private static class EnabledAnnotatedMultiValue { public void nonAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
@DirtiesContext(classMode = BEFORE_CLASS) static class DirtiesContextDeclaredLocallyBeforeClass { void clean() { /* no-op */ } }
@DirtiesContext(classMode = ClassMode.AFTER_CLASS) static class ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase extends BaseTestCase { @org.testng.annotations.Test void verifyContextWasAutowired() { assertApplicationContextWasAutowired(); } }
/** * @author Sam Brannen * @since 4.3 */ @DirtiesContext interface DirtiesContextTestInterface { }
@DirtiesContext(classMode = ClassMode.AFTER_CLASS) public static class ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase extends BaseTestCase { @Test public void verifyContextWasAutowired() { assertApplicationContextWasAutowired(); } }
@DirtiesContext(classMode = AFTER_CLASS) static class DirtiesContextDeclaredLocallyAfterClass { void clean() { /* no-op */ } }
@DirtiesContext static class ClassLevelDirtiesContextWithDirtyMethodsTestCase extends BaseTestCase { @org.testng.annotations.Test @DirtiesContext void dirtyContext() { assertApplicationContextWasAutowired(); } }
@DirtiesContext public static class ClassLevelDirtiesContextWithDirtyMethodsTestCase extends BaseTestCase { @Test @DirtiesContext public void dirtyContext() { assertApplicationContextWasAutowired(); } }
/** * {@link DirtiesContext} is declared at the class level, specifying the * {@link DirtiesContext.HierarchyMode#CURRENT_LEVEL CURRENT_LEVEL} hierarchy mode. * <p>After running this test class, the context cache should be cleared * beginning from the current context hierarchy and down through all subhierarchies. */ @DirtiesContext(hierarchyMode = HierarchyMode.CURRENT_LEVEL) public static class ClassLevelDirtiesContextWithCurrentLevelModeTestCase extends BazTestCase { @Test public void test() { } }
@DirtiesContext static class ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase extends BaseTestCase { @org.testng.annotations.Test void verifyContextWasAutowired() { assertApplicationContextWasAutowired(); } }
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD) static class DirtiesContextDeclaredLocallyAfterEachTestMethod { void clean() { /* no-op */ } }