简体   繁体   中英

Make test run in parallel using testNG

I want to write parallel tests using TestNG.

I have 3 methods these are testLogin(), testWrite() and testRead() and My system has 100 users. Each method must follow each other, for example testLogin()'s priority is 1, testWrite()'s priority is 2 and testRead()'s priority is 3. How can I test these system calling these methods paralel.

Parallel tests are not very recommendable since they are not repeatable. Each invocation of a test might follow a different execution path and might therefore succeed or fail randomly. I recommend you a proper concurrency testing framework such as thread weaver where you can define thread break points explicitly.

TestNG can be told to run a test several times by for example setting @Test(threadCount = 10, invocations = 100) for 10 threads running a method 100 times in total. (Don't do it.) If you want to run different methods parallel inside one test, you need to write such code yourself by creating custom threads that are started parallel. (Don't do it either.)

While it is true that parallel testing may cause failures but it not impossible to achieve parallelism if tests are properly designed and developed. In fact you can get the best value of automation testing when scripts can be executed parallely using proper tools(Selenium Grid).

See here an example of how to achieve parallelism using webdriver+testng.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM