Wrong number of test executions when a TestNG suite xml calls other suite xmls

106 views
Skip to first unread message

ngogovski

unread,
Feb 22, 2012, 9:33:45 AM2/22/12
to testng-dev
Hello TestNG guys,

We have hit a problem with latest TestNG Eclipse plugin when calling a
testNG suite xml from another suite xml.

Here is how to reproduce the problem:
1. Create a simple java project with 1 class <PROJECT ROOT>/src/com/
Test1Class.java which has just 1 test method.
2. Create 2 suite xml files placed in <PROJECT ROOT>/suites:
2.1. the first xml is called suite1.xml and has the following content:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite1" verbose="1">
<test name="Suite1 tests">
<classes>
<class name="com.Test1Class" />
</classes>
</test>
</suite>

2.2. the second xml is called complex_suite.xml and has the following
content:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Complex suite" verbose="1">
<suite-files>
<suite-file path="suites/suite1.xml" />
</suite-files>
</suite>

Now run the complex_suite.xml and you will get the following output in
the console:

[TestNG] Running:
D:\Eclipse_workspace\TestTestNG\suites\suite1.xml

running testMethod1()

===============================================
Suite1
Total tests run: 1, Failures: 0, Skips: 0
===============================================

[TestNG] Running:
D:\Eclipse_workspace\TestTestNG\suites\suite1.xml

running testMethod1()

===============================================
Suite1
Total tests run: 2, Failures: 0, Skips: 0
===============================================

[TestNG] Running:
D:\Eclipse_workspace\TestTestNG\suites\complex_suite.xml


===============================================
Complex suite
Total tests run: 4, Failures: 0, Skips: 0
===============================================

As you can see the test method is called twice, while expected only
one execution.


It is interestig to note that changing the complex_suite.xml to:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Complex suite" verbose="1">
<suite-files>
<suite-file path="suite1.xml" />
</suite-files>
</suite>

produces the following output in the console:

java.io.FileNotFoundException: D:\Eclipse_workspace\TestTestNG
\suite1.xml (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at org.testng.xml.Parser.parse(Parser.java:165)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:271)
at org.testng.TestNG.run(TestNG.java:980)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
[TestNG] Running:
D:\Eclipse_workspace\TestTestNG\suites\suite1.xml

running testMethod1()

===============================================
Suite1
Total tests run: 1, Failures: 0, Skips: 0
===============================================

[TestNG] Running:
D:\Eclipse_workspace\TestTestNG\suites\complex_suite.xml


===============================================
Complex suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================

So it complains it cannot find the internal suite1.xml, but indeed
runs the test method just once as expected.

I've tried calling many internal suites from the complex one and the
issue is the same: all tests are run once and then are run once again
in the same order.

thank you for your help :)
Nikolay
Reply all
Reply to author
Forward
0 new messages