01: package test.skipex;
02:
03: import java.util.List;
04:
05: import org.testng.Assert;
06: import org.testng.ITestResult;
07: import org.testng.TestListenerAdapter;
08: import org.testng.TestNG;
09: import org.testng.annotations.Test;
10:
11: /**
12: * This class/interface
13: */
14: public class SkippedExceptionTest {
15: @Test
16: public void skippedExceptionInConfigurationMethods() {
17: TestListenerAdapter listener = new TestListenerAdapter();
18: TestNG test = new TestNG(false);
19: test.addListener(listener);
20: test.setVerbose(0);
21: test
22: .setTestClasses(new Class[] { ConfigurationSkippedExceptionTest.class });
23: test.run();
24: List<ITestResult> confSkips = listener.getConfigurationSkips();
25: List<ITestResult> testSkips = listener.getSkippedTests();
26: Assert.assertEquals(testSkips.size(), 1);
27: Assert.assertEquals(testSkips.get(0).getMethod()
28: .getMethodName(), "dummyTest");
29:
30: // FIXME: currently there is no way to register IConfigurationListener
31: // Assert.assertEquals(confSkips.size(), 1);
32: // Assert.assertEquals(confSkips.get(0).getMethod().getMethodName(), "configurationLevelSkipException");
33: }
34:
35: @Test
36: public void skippedExceptionInTestMethods() {
37: TestListenerAdapter listener = new TestListenerAdapter();
38: TestNG test = new TestNG(false);
39: test.addListener(listener);
40: test.setVerbose(0);
41: test
42: .setTestClasses(new Class[] { TestSkippedExceptionTest.class });
43: test.run();
44: List<ITestResult> skips = listener.getSkippedTests();
45: List<ITestResult> failures = listener.getFailedTests();
46: Assert.assertEquals(skips.size(), 1);
47: Assert.assertEquals(failures.size(), 1);
48: Assert.assertEquals(skips.get(0).getMethod().getMethodName(),
49: "genericSkipException");
50: Assert.assertEquals(
51: failures.get(0).getMethod().getMethodName(),
52: "timedSkipException");
53: }
54: }
|