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