01: package test.failures;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import org.testng.TestNG;
07: import org.testng.annotations.Test;
08: import org.testng.xml.XmlSuite;
09:
10: import test.TestHelper;
11:
12: public class FailuresTest extends BaseFailuresTest {
13:
14: @Test
15: public void shouldIncludeFailedMethodsFromBaseClass() {
16: XmlSuite suite = TestHelper.createSuite("test.failures.Child",
17: 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: verify(getOutputDir(), expected);
27: }
28:
29: @Test(enabled=false)
30: public void shouldIncludeDependentMethods() {
31: XmlSuite suite = TestHelper.createSuite(
32: "test.failures.DependentTest", getSuiteName());
33: TestNG tng = TestHelper.createTestNG(suite);
34: tng.run();
35:
36: String[] expected = new String[] { "<include name=\"f1\"/>",
37: "<include name=\"f2\"/>" };
38:
39: verify(getOutputDir(), expected);
40: }
41:
42: @Test(enabled=false)
43: public void shouldIncludeParameters() {
44: XmlSuite suite = TestHelper.createSuite("test.failures.Child",
45: getSuiteName());
46: Map<String, String> params = new HashMap<String, String>();
47: params.put("first-name", "Cedric");
48: params.put("last-name", "Beust");
49: suite.setParameters(params);
50:
51: TestNG tng = TestHelper.createTestNG(suite);
52: tng.run();
53:
54: String[] expected = new String[] { "<parameter name=\"first-name\" value=\"Cedric\"/>", };
55:
56: verify(getOutputDir(), expected);
57: }
58:
59: private String getOutputDir() {
60: return System.getProperty("java.io.tmpdir");
61: }
62:
63: private static void ppp(String s) {
64: System.out.println("[FailuresTest] " + s);
65: }
66: }
|