Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
967 views
in Technique[技术] by (71.8m points)

selenium - How to run the test classes in particular order using SeleniumWebDriver(Java) with TestNG?

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

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

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.7k users

...