1 package test.failures;
2 
3 
4 import org.testng.TestNG;
5 import org.testng.annotations.Test;
6 import org.testng.xml.XmlSuite;
7 
8 import test.TestHelper;
9 
10 import java.util.HashMap;
11 import java.util.Map;
12 
13 public class FailuresTest extends BaseFailuresTest {
14 
15   @Test
shouldIncludeFailedMethodsFromBaseClass()16   public void shouldIncludeFailedMethodsFromBaseClass() {
17     XmlSuite suite = TestHelper.createSuite("test.failures.Child", getSuiteName());
18     TestNG tng = TestHelper.createTestNG(suite);
19     tng.run();
20 
21      String[] expected = new String[] {
22        "<class name=\"test.failures.Child\">",
23        "<include name=\"fail\"/>",
24        "<include name=\"failFromBase\"/>",
25      };
26 
27      verify(getOutputDir(), expected);
28   }
29 
30   @Test(enabled = false)
shouldIncludeDependentMethods()31   public void shouldIncludeDependentMethods() {
32     XmlSuite suite = TestHelper.createSuite("test.failures.DependentTest", getSuiteName());
33     TestNG tng = TestHelper.createTestNG(suite);
34     tng.run();
35 
36     String[] expected = new String[] {
37         "<include name=\"f1\"/>",
38         "<include name=\"f2\"/>"
39       };
40 
41     verify(getOutputDir(), expected);
42   }
43 
44   @Test(enabled = false)
shouldIncludeParameters()45   public void shouldIncludeParameters() {
46     XmlSuite suite = TestHelper.createSuite("test.failures.Child", getSuiteName());
47     Map<String, String> params = new HashMap<>();
48     params.put("first-name", "Cedric");
49     params.put("last-name", "Beust");
50     suite.setParameters(params);
51 
52     TestNG tng = TestHelper.createTestNG(suite);
53     tng.run();
54 
55     String[] expected = new String[] {
56         "<parameter name=\"first-name\" value=\"Cedric\"/>",
57       };
58 
59     verify(getOutputDir(), expected);
60   }
61 
getOutputDir()62   private String getOutputDir() {
63     return System.getProperty("java.io.tmpdir");
64   }
65 
ppp(String s)66   private static void ppp(String s) {
67     System.out.println("[FailuresTest] " + s);
68   }
69 }
70