代码简单易懂,下面给一个测试类:
package com.demo;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
@Listeners({com.demo.NewReport.class})
public class Test15 {
@DataProvider
public Object[][] dataProvider(){
return new Object[][]{{1},{2}};
}
@Test(dataProvider="dataProvider")
public void testAssert1(int a){
Assert.assertEquals(1, a);
}
@Test
public void testAssert2(){
Assert.assertEquals("2", "2");
}
}
运行后,大家打开test-output文件夹,看是不是多了个test.txt的文件夹。截图如下: