我将此@DataProvider
定义为此
public class A {
@BeforeTest
@DataProvider(name = "ProvideUsefulClasses")
public static Object[][] InitiateUsefulClasses() throws MalformedURLException {
PageObjectOne pageObjOne = new PageObjectOne();
AndroidDriver driver=pageObjOne.driver;
TouchAction touchAction = new TouchAction(driver);
WebDriverWait wait = new WebDriverWait(driver, 20000);
return new Object[][] {
{touchAction, wait},{driver,pageObjOne}
} ;
}
}
我在不同的班级中收到它
@Test(dataProvider = "ProvideUsefulClasses",dataProviderClass=A.class)
class testMethods {
public static TouchAction tAction;
public static WebDriverWait Wait;
public static AndroidDriver Driver;
public static PageObjectOne PageObjectOneInst;
@Test(priority=1,dataProvider = "ProvideUsefulClasses",dataProviderClass=A.class)
public static void AgreeAllow(Object[][] UsefulClasses) throws InterruptedException{
tAction = ((TouchAction) UsefulClasses[0][0]);
Wait= ((WebDriverWait) UsefulClasses[0][1]);
Driver = ((AndroidDriver) UsefulClasses[1][0]);
PageObjectOneInst = ((PageObjectOne) UsefulClasses[1][1]);
...
...
}
}
但我收到错误
FAILED: AgreeAllow
org.testng.internal.reflect.MethodMatcherException:
Data provider mismatch
Method: AgreeAllow([Parameter{index=0, type=[[Ljava.lang.Object;, declaredAnnotations=[]}])
Arguments: [(io.appium.java_client.TouchAction)io.appium.java_client.TouchAction@29c5ee1d,(org.openqa.selenium.support.ui.WebDriverWait)org.openqa.selenium.support.ui.WebDriverWait@15cea7b0]
at org.testng.internal.reflect.DataProviderMethodMatcher.getConformingArguments
看起来,从错误的角度看,我没有正确接收或返回数据,这里丢失了什么?
我希望只有在不能以这种方式完成时才使用@factory
。
我还没有尝试使用@factory
解决它,我必须搜索。
ADDITION:我找到了this,但它只传递了一个班级。我们如何为多个班级做这件事?
答案 0 :(得分:0)
当我在var tls=require("tls")
var https=require("https")
var options={
host:"example.com",
port:443,
path:"/"
}
var agentOptions = {
rejectUnauthorized: true //this option disables certificate verification when it is false, you may need to disable it to connect to a server without having SNI enabled
}
var agent = new https.Agent(agentOptions)
agent.createConnection=function(options,callback){
options.servername=undefined //setting servername to undefined disables SNI
return socket=tls.connect(options,callback)
}
options.agent=agent
request=https.request(options,function(response){
response.on("data",function(data){
console.log(data.toString())
})
})
request.end()
方法
return
语句更改为以下内容时,该错误消失了
@dataprovider
我还将接收方法的定义更改为
return new Object[][] {
{ touchAction, wait,driver,pageObjOne}
} ;