1
votes

To reduce run time of my tests I want to run my tests in parallel. I have few classes that I can't run in parallel to each other.

lets say I have two types of classes: - parallel Classes - contains class1, class2 - NotParallel Classes - contains class3, class4 I want to run class1 and class2 in parallel to class3 and class4 (but lass3 will not run in parallel to class4)

I tried to do this:

<suite name="sanity"  thread-count="2" parallel="tests">
    <test name="parallel" preserve-order="true" parallel="classes">
        <classes>           
            <class name="class1"/> 
            <class name="class2"/> 
        </classes>  
    </test>
    <test name="NotParallel" preserve-order="true">
        <classes>           
            <class name="class3"/>  
            <class name="class4"/>
        </classes>

    </test>
</suite>

I'm running both tests in parallel but just the first test have the parallelism for class inside it.

I tried to search in TestNG documentation if I have the option to add the parallel="classes" to test. I don't see it there, but it is working.

Does anyone used this option to parallel test classes (and not suite)

do you see any issue or case where it will not work?

Thanks

1

1 Answers

2
votes

Yes you can put parallel in a <test> block. Here is the DTD.

You could also establish a <suite> of suites to suit your needs as follows;

<suite ...>
    <suite-files>
        <suite-file path="a.xml" />
        <suite-file path="b.xml" />
    <suite-files>
</suite>