testng thread pool configuration, execution count configuration, timeout configuration

Source: Internet
Author: User
Tags testng

Use annotations for testng thread pool configuration, execution count configuration, timeout configuration

Note: Use annotations to control the number of times the test method runs and time out, timeout in single-threaded or multithreaded mode is available, ThreadPoolSize set the number of thread pool *, when observing the results, found that many values are duplicated, but may not be equal to the number of thread pool we configured, Because the number of threads also depends on the support of the hardware CPU,

Invocationcount----Indicates the number of executions

ThreadPoolSize-----Indicates the number of threads in the thread pool

Timeout-------time-out-milliseconds

Java Code:

[Java]View PlainCopy 
  1. /**
  2. *
  3. * <p>
  4. * Title:testnginvocationcount
  5. * </p>
  6. *
  7. * <p>
  8. * Description:
  9. * Use annotations to control the number of times the test method runs and time out, timeout is available in single-threaded or multithreaded mode, ThreadPoolSize sets the number of thread pools
  10. *, when observing the results, we find that many values are duplicated, but may not be equal to the number of thread pool threads we configured, because the number also depends on the hardware CPU support.
  11. * </p>
  12. *
  13. * <p>
  14. * Company:
  15. * </p>
  16. *
  17. * @author: Dragon
  18. *
  19. * @date: October 22, 2014
  20. */
  21. Public class Testnginvocationcount {
  22. private static int sum = 0;
  23. @Test (ThreadPoolSize = 2, Invocationcount = ten, TimeOut = + )
  24. public void TestServer () throws interruptedexception {
  25. //detect the number of threads started, when the number of boot is more than the number of CPU cores, is actually re-scheduling
  26. //Thread.Sleep (2000);
  27. sum++;
  28. System.out.println ("..." + sum);
  29. }
  30. }



Test results:

[HTML]View PlainCopy  
  1. [Threadutil] Starting executor timeout:1000ms workers:10 Threadpoolsize:3
  2. ......... 2
  3. ......... 2
  4. ......... 2
  5. ......... 3
  6. ......... 4
  7. ......... 5
  8. ......... 6
  9. ......... 7
  10. ......... 8
  11. ......... 9
  12. Passed:testserver
  13. Passed:testserver
  14. Passed:testserver
  15. Passed:testserver
  16. Passed:testserver
  17. Passed:testserver
  18. Passed:testserver
  19. Passed:testserver
  20. Passed:testserver
  21. PASSED: testserver
  22. ===============================================
  23. Default Test
  24. Tests run:10, failures:0, skips: 0
  25. ===============================================

testng thread pool configuration, execution count configuration, timeout configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.