TestNG Dependency Configuration Base usage (single method dependent)------testng dependencies (i)

Source: Internet
Author: User
Tags testng

TestNG relies on simple method dependencies for testing, configuring dependent methods through the Dependsonmethods property

Original articles, all rights reserved, permitted reprint, Mark Source: Http://blog.csdn.net/wanghantong

Java Code:

[Java]View PlainCopy 
  1. /**
  2. *
  3. * <p>
  4. * Title:testngdependencies
  5. * </p>
  6. *
  7. * <p>
  8. * Description:testng provides two kinds of dependency implementations
  9. *
  10. * 1. Forced dependency: If there is a failure in a dependency chain that needs to be executed before a test case, then all of the tests will not be executed
  11. * 2. Sequential dependencies (soft dependencies): The usefulness of sequential dependencies is more used to detect whether a test chain executes in the correct order, even if one of the use cases fails, but does not affect the execution of the entire test chain
  12. * Dependsonmethods
  13. * (If the dependent method has multiple overloaded methods, all overloaded methods will be executed, and if you want to execute only one method, use dependsongroups)
  14. * </p>
  15. *
  16. * <p>
  17. * Company:
  18. * </p>
  19. *
  20. * @author: Dragon
  21. *
  22. * @date: October 13, 2014
  23. */
  24. Public class Testngdependencies {
  25. @Test
  26. public void Serverstartedok () {
  27. System.err.println ("method1 runs after me ...");
  28. }
  29. @Test (dependsonmethods = { "Serverstartedok"})
  30. public void Method1 () {
  31. System.err.println ("I am depended on serverstartedok ...");
  32. }
  33. }


Configuration file:

[HTML]View PlainCopy 
  1. <? XML version= "1.0" encoding="UTF-8"?>
  2. <! DOCTYPE Suite SYSTEM "Http://testng.org/testng-1.0.dtd">
  3. <suite name="framework_testng" allow-return-values="true">
  4. <test verbose="2" name= "testngdependencies">
  5. <classes>
  6. <class name="com.dragon.testng.annotation.TestngDependencies">
  7. </class>
  8. </Classes>
  9. </Test>
  10. </Suite>


Operation Result:

[HTML]View PlainCopy  
    1. Method1 runs after me ...
    2. I am depended on serverstartedok ...
    3. Passed:serverstartedok
    4. PASSED: method1
    5. ===============================================
    6. Testngdependencies
    7. Tests Run:2, failures:0, skips: 0
    8. ===============================================

TestNG Dependency Configuration base usage (single method dependent)------testng dependencies (i)

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.