Reputation: 39
How to run two classes in parallel in testng one with parameters and one without parameters. I have following classes:
class A (has no parameters) Class B (has parameters) Class C (has no parameters)
Q.1: how can i configure my ".xml" if i to run Class A & class B in parallel and then class C ?
Upvotes: 0
Views: 254
Reputation: 14736
When using TestNG 6.12 (Its yet to be released as we speak) you would use it like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="1265_Suite" parallel="classes" verbose="2">
<test name="One">
<classes>
<class name="com.rationaleemotions.stackoverflow.ParameterizedClass">
<parameter name="browsername" value="firefox"/>
</class>
<class name="com.rationaleemotions.stackoverflow.ChildClassOne">
<parameter name="foo" value="bar"/>
</class>
</classes>
</test>
</suite>
Once TestNG 6.12 is released, you wouldnt need to do the following (because there was a bug that was fixed related to class level <parameters>
) but until then you can do something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="1265_Suite" parallel="tests" verbose="2">
<test name="One">
<parameter name="browsername" value="firefox"/>
<classes>
<class name="com.rationaleemotions.stackoverflow.ParameterizedClass">
</class>
</classes>
</test>
<test name="Two">
<classes>
<class name="com.rationaleemotions.stackoverflow.AnotherClass">
</class>
</classes>
</test>
</suite>
Upvotes: 2
Reputation: 17553
You need to add in xml parallel="methods"
and thread-count="2"
like below :-
<suite name="Parallel test suite" parallel="methods" thread-count="2">
I haven't try but there should be no problem if you not using parameter in any of class as parameter annotation is just used to feed your data. Just don't define parameter for the test you are not using or just not use annotation of Parameters where you don't want it
Example :-
https://www.tutorialspoint.com/testng/testng_parameterized_test.htm
Upvotes: 0