Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to run the Selenium WebDriver (Java) test classes in the particular order using TestNG.

For eg. I have 3 classes such as Test1, Test2 and Test3. I want to run in the order Test2, Test1 and Test3. Is it possible without grouping?

I tried the following way, but I runs in its own order (Alphabetical order).

<suite name="MyTestSuite" verbose="4">

<test name="MyTest">
   <classes>
        <class name="com.mypackage.Test2" />
        <class name="com.mypackage.Test1" />
        <class name="com.mypackage.Test3" />
   </classes>
</test>

Is there any other way to do this? Without grouping is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
958 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just use preserve-order="true" to make classes to run in given order.

<suite name="MyTestSuite" verbose="4">

<test name="MyTest" >
   <classes preserve-order="true">
        <class name="com.mypackage.Test2" />
        <class name="com.mypackage.Test1" />
        <class name="com.mypackage.Test3" />
   </classes>
</test>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...