Testng dependency description (1) ------ simple dependency (single method dependency)

Source: Internet
Author: User
Tags testng

Simple Method dependency for testng dependency test. Use the dependsonmethods attribute to configure the dependency method.


Java code:

/***** <P> * Title: testngdependencies * </P> ** <p> * Description: testng provides two dependency implementations ** 1. mandatory dependency: if one of the dependency chains to be executed before a test case fails, all subsequent tests will not be executed * 2. sequential dependency (soft dependency): it is used to detect whether a test chain is executed in the correct order, even if one of the test cases fails to be executed, but it will not affect the execution of the entire test chain * dependsonmethods * (if the dependent method has multiple overloaded methods, all the overloaded methods will be executed. If you only want to execute one method, use dependsongroups) * </P> ** <p> * company: * </P> ** @ Author: Dragon ** @ Date: october 13, 2014 */public class testngdependencies {@ testpublic void serverstartedok () {system. err. println ("Method1 runs after me ...... ") ;}@ test (dependsonmethods = {" serverstartedok "}) Public void Method1 () {system. err. println ("I am depended on serverstartedok ...... ");}}

Configuration file:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"><suite name="framework_testng" allow-return-values="true"><test verbose="2" name="TestngDependencies"><classes><class name="com.dragon.testng.annotation.TestngDependencies"></class></classes></test></suite>

Running result:

method1 runs after me......I am depended on serverStartedOk......PASSED: serverStartedOkPASSED: method1===============================================    TestngDependencies    Tests run: 2, Failures: 0, Skips: 0===============================================





Testng dependency description (ii) ----- mandatory dependency and sequential dependency

If I am sincere,
Don't say it to me. Because I understand,
You are responsible for coping against your inception, and loyal words against your ears.

Testng dependency description (1) ------ simple dependency (single method dependency)

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.