下面是部分 java 代码

protected ImplementationScreen impScreen;
protected String methodName;

@BeforeClass(alwaysRun = true)
@Parameters(value = { "deviceName", "platformName", "platformVersion", })
public void setup(String deviceName, String platformName, String platformVersion) {
    TestNgParameters tngparam = new TestNgParameters();
    tngparam.getDeviceName().put("deviceName", deviceName);
    tngparam.getPlatformName().put("platformName", platformName);
    tngparam.getPlatformVersion().put("platformVersion", platformVersion);  
    impScreen = new ImplementationScreen(tngparam);

}

下面是报错信息:

[TestNG] Running:
  /private/var/folders/8q/c2df2pbx7klbysvszjxxbj580000gn/T/testng-eclipse-2043619497/testng-customsuite.xml

FAILED CONFIGURATION: @BeforeClass setup
org.testng.TestNGException: 
Parameter 'deviceName' is required by @Configuration on method setup but has not been marked @Optional or defined
in /private/var/folders/8q/c2df2pbx7klbysvszjxxbj580000gn/T/testng-eclipse-2043619497/testng-customsuite.xml
    at org.testng.internal.Parameters.createParameters(Parameters.java:155)
    at org.testng.internal.Parameters.createParameters(Parameters.java:358)
    at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:86)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:199)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

提示的主要错误是:该如何处理?请前辈指教、谢谢

Parameter 'deviceName' is required by @Configuration on method setup but has not been marked 


↙↙↙阅读原文可查看相关链接,并与作者交流