简体   繁体   中英

TestNG dependsOnMethods

package test;

import org.testng.annotations.Test;

public class Day3 {

    @Test
    public void webLoginCarLoan() {
        System.out.println("WebLoginCarLoan");
    }

    @Test
    public void mobileLoginCarLoan() {
        System.out.println("MobileLoginCarLoan");
    }

    @Test
    public void mobileSignoutCarLoan() {
        System.out.println("MobileSignoutCarLoan");
    }

    @Test(dependsOnMethods = { "webLoginCarLoan" })
    public void apiCarLoan() {
        System.out.println("LoginAPICarLoan");
    }

}

Output:

MobileLoginCarLoan
WebLoginCarLoan
MobileSignoutCarLoan
LoginAPICarLoan

Why WebLoginCarLoan comes before MobileSignoutCarLoan in Output?

TestNG does not execute tests in same order as noted in class. If you think, need to execute tests/@Test methods in specified order then use priority

 @Test(priority=1)

Also as pointed by Mark "I think that dependsOnMethods will make sure webLoginCarLoan is executed before apiCarLoan however not immediately after it perse"

see in Java Doc https://jitpack.io/com/github/cbeust/testng/master/javadoc/org/testng/annotations/Test.html#dependsOnMethods--

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