(X) TestNG multiple threads running use case

TestNG is the only self-supporting multi-process technology unit testing framework I have come across. While the code-level unit tests run very fast, multi-threaded significance is not large. But if the UI automated test, then the speed will be very slow, this time multithreading technology will become very important.

Multithreading Configuration


Here only testng.xml file, use one of the test cases, refer to previous chapters created. <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="测试套件" parallel="classes" thread-count="2" > <test name="简单测试"> <classes> <class name="test.sample.FirstTest" /> <class name="test.sample.SecondTest" /> </classes> </test> </suite> * Set the level of division parallel multi-threaded. * Parallel = "methods": TestNG will run all the test methods in different threads. Dependent method will also run in a separate thread, but they will respect the order you specify.

  • parallel = "tests": TestNG will run the same mark all methods in the same thread, but each tag will in a separate thread. This allows you to all non-thread-safe grouped in the same class in, and to ensure that they will run in the same thread, while taking advantage of as many threads to run the test.

  • parallel = "classes": TestNG methods will run all the same class in the same thread, but each class will run in a separate thread.

  • parallel = "instances": TestNG will run all the same manner as Example in the same thread, but the two methods on two different instances will run in different threads.

    • thread-count is used to specify the number of threads.

Guess you like

Origin www.cnblogs.com/xinlan06/p/11498781.html