01: package test.failedconfs;
02:
03: import org.testng.Assert;
04: import org.testng.TestListenerAdapter;
05: import org.testng.TestNG;
06:
07: import testhelper.OutputDirectoryPatch;
08:
09: public class FailedBeforeTestMethodConfigurationBehaviorTest {
10: static boolean s_failedBeforeTestMethodInvoked = false;
11: static int s_noFailureClassMethods;
12: public static int s_failureClassMethods;
13:
14: /**
15: * @testng.before-method
16: */
17: public void init() {
18: System.out.println("init");
19: s_failedBeforeTestMethodInvoked = false;
20: s_noFailureClassMethods = 0;
21: s_failureClassMethods = 0;
22: }
23:
24: /**
25: * @testng.test enabled=false description="Test1 and Test2 are not triggered"
26: */
27: public void beforeTestMethodFailureInTwoClasses() {
28: TestNG testng = new TestNG();
29: testng.setSourcePath("./test-14/src;src");
30: testng.setAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
31: testng.setTestClasses(new Class[] { Test1.class, Test2.class });
32: testng.setVerbose(0);
33: testng.setOutputDirectory(OutputDirectoryPatch
34: .getOutputDirectory());
35: testng.run();
36:
37: Assert.assertTrue(s_failedBeforeTestMethodInvoked,
38: "failing @BeforeTestMethod should have been invoked");
39: Assert.assertEquals(s_noFailureClassMethods, 2,
40: "both methods in " + Test2.class.getName()
41: + " should have been called");
42: Assert.assertEquals(s_failureClassMethods, 0,
43: "no test method in " + Test1.class.getName()
44: + " should have been called");
45:
46: }
47: }
|