1package test;
2
3import java.util.Arrays;
4
5import org.testng.Assert;
6import org.testng.TestListenerAdapter;
7import org.testng.TestNG;
8import org.testng.annotations.Test;
9
10/**
11 * Check for a bug in how relative paths in suite files were being handled.
12 *
13 * All paths were being resolved using the initial suite's location and not
14 * that of the current suite being parsed/processed.
15 *
16 * This test checks that TestNG can handle cases where we have the following set of
17 * files (all linked using relative paths):
18 *
19 * - parent-suite -> [child-suite-1, children/child-suite-3]
20 * - children/child-suite-3 -> [../child-suite-2, child-suite-4, morechildren/child-suite-5]
21 *
22 * Check the <code>checksuitesinitialization</code> folder under test resources
23 *
24 * @author Nalin Makar
25 */
26public class CheckSuitesInitializationTest extends SimpleBaseTest {
27
28  /**
29   * Child suites and tests within different suites have same names
30   */
31  @Test
32  public void check() {
33    TestListenerAdapter tla = new TestListenerAdapter();
34    TestNG tng = create();
35    String testngXmlPath = getPathToResource("checksuitesinitialization/parent-suite.xml");
36    tng.setTestSuites(Arrays.asList(testngXmlPath));
37    tng.addListener(tla);
38    tng.run();
39    Assert.assertEquals(tla.getPassedTests().size(), 4);
40  }
41
42}
43