我在使用Arquillian测试中使用@DataProvider时遇到问题所以我编写了一个简单的测试来查看数据是如何执行的。我的目标是执行我的一次,所以应该有两个打印“LOGS Data is ...”
相反,我让他们执行了两次(四次打印)。我想问你们这是为什么以及如何解决它。
这是一个简单的代码:
@DataProvider(name = "addMethodDataProvider")
public Object[][] dataProviderMethod()
{
return new Object[][] { { "param one-one", "param two-one" }, { "param one-two", "param two-two" } };
}
@Test(dataProvider = "addMethodDataProvider")
public void testMethod(String data, String data1)
{
System.out.println("Data is: " + data + " & "+ data1 );
}
输出样本:
14:41:55,660 INFO [stdout] (http-localhost/127.0.0.1:8080-1) Data is: param one-one & param two-one
14:41:55,777 INFO [stdout] (http-localhost/127.0.0.1:8080-1) Data is: param one-two & param two-two
14:41:56,043 INFO [stdout] (http-localhost/127.0.0.1:8080-2) Data is: param one-one & param two-one
14:41:56,164 INFO [stdout] (http-localhost/127.0.0.1:8080-2) Data is: param one-two & param two-two