美文网首页
TestNG 重写TestCase框架方法

TestNG 重写TestCase框架方法

作者: BestFei | 来源:发表于2020-05-14 13:17 被阅读0次

一、重写TestCase

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;


import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.ITest;
import org.testng.ITestContext;
import org.testng.Reporter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;

@Listeners({ReportListener.class})
public class TestCase extends AbstractTestNGSpringContextTests implements ITest {

    public TestCase() {
    }

    @BeforeMethod
    public void BeforeMethod(Method method, Object[] testData) {
       

    }

    @AfterMethod
    public void afterMethod(Method method, Object[] testData) {
        this.steps.clear();
    }

    @BeforeClass(
        alwaysRun = true
    )
    public void beforeScenario() {
    }

    @AfterClass(
        alwaysRun = true
    )

    @DataProvider(name = "providerTestCaseData")
    public Object[][] providerTestData(Method method, ITestContext context) throws IOException {
        Object[][] ret = (Object[][])null;
        // ...
        return ret;

    }

}

二、业务测试类继承重写的TestCase

public class LoginTest extends TestCase {
        
    @TestCaseDesc(author = "best.fei",version = "1.0.0",)
    @CaseDataSource(filename = "loginTestData.json")
    @Test(dataProvider = "providerTestCaseData")
    public void testNormalLogin(InputParam inputParam) throws Exception {

}

相关文章

网友评论

      本文标题:TestNG 重写TestCase框架方法

      本文链接:https://www.haomeiwen.com/subject/bvktohtx.html