I have the following Maven structure for my automation project
qa-automation-module (root maven module)
==> Pom.xml(Grand Parent pom)
==> company-module
==> Pom.xml (parent pom)
====> orders-module
==> Pom.xml (child pom)
==> src\test\java\com.orders_package (java package)
==> OrdersTest.java
==> orders_testng.xml
====> invoices-module
==> Pom.xml (child pom)
==> src\test\java\com.invoices_package (java package)
==> InvoicesTest.java
==> invoices_testng.xml
==> AllSuites.xml
orders_testng.xml
-----------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "
http://testng.org/testng-1.0.dtd">
<suite verbose="2" name="SINGLE TEST RUN ORDERS" thread-count="1">
<test name="Orders Test">
<parameter name="module" value="Orders"></parameter>
<classes>
<class name="com.orders_package.OrdersTest"/>
</classes>
</test>
</suite>
invoices_testng.xml
-------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "
http://testng.org/testng-1.0.dtd">
<suite verbose="2" name="SINGLE TEST RUN INVOICES" thread-count="1">
<test name="Invoices Test">
<parameter name="module" value="invoices"></parameter>
<classes>
<class name="com.invoices_package.InvoicesTest"/>
</classes>
</test>
</suite>
I can run each testng.xml file from their respective locations with out any errors.
However i would like to combine them into one suite file.
hence I have created a Suite-file named AllSuites.xml
AllSuites.xml
----------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "
http://testng.org/testng-1.0.dtd">
<suite verbose="2" name="SINGLE TEST RUN - UK - Chrome" thread-count="2" parallel="classes">
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter"></listener>
</listeners>
<suite-files>
<suite-file path="/invoices_testng.xml"/>
<suite-file path="../orders_testng.xml"/>
</suite-files>
</suite>
When I run AllSuites.xml, I get the following error message in the console
org.testng.TestNGException:
Cannot find class in classpath: com.orders_package.OrdersTest
at org.testng.xml.XmlClass.loadClass(XmlClass.java:81)
at org.testng.xml.XmlClass.init(XmlClass.java:73)
at org.testng.xml.XmlClass.<init>(XmlClass.java:59)
at org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler.java:543)
from the error message I can deduce that the path ../orders_testng.xml is not the problem because it
reads the xml file correctly and hence displays the name of the test I want to run i.e. OrderTest, but I do not
understand why its displaying "Cannot find class in classpath: com.orders_package.OrdersTest"
If I remove this line <suite-file path="/invoices_testng.xml"/> from AllSuites.xml and move AllSuites.xml into orders-module folder and run it from there,
it runs perfectly and does not complain about Cannot find class in classpath: com.orders_package.OrdersTest, so the class file
ordersTest.class is there alright.
How can I combine my two testng.xlm files, i.e. invoices_testng.xml and orders_testng.xml into
one suite file and run them succesfully without getting them error "Cannot find class in classpath: com.orders_package.OrdersTest"
Any pointers will be very much appreciated.
Thanks
Vasty