51Testing软件测试论坛

标题: TestNG 参数传递问题求助! [打印本页]

作者: mashenka123    时间: 2016-5-19 00:51
标题: TestNG 参数传递问题求助!
error: FAILED CONFIGURATION: @BeforeClass startDriver
org.testng.TestNGException:
Parameter 'language' is required by @Configuration on method startDriver but has not been marked @Optional or defined

My xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test name="Testfr">
    <parameter name="language" value="fr" />   
    <classes>
      <class name="com.rachel.sametimeauto.appium.iOS.MeetingsTest.iOSMeetingsTVTSanityTest"/>
    </classes>
  </test>  
  <test name="Testde">
    <parameter name="language" value="de"/>   
    <classes>
      <class name="com.rachel.sametimeauto.appium.iOS.MeetingsTest.iOSMeetingsTVTSanityTest"/>
    </classes>
  </test>
</suite>

My code:       
        @BeforeClass(alwaysRun = true)
        @Parameters("language")
        public void startDriver(String language) throws Exception{
          driver=driverFactory.getIOSDriver(language,service);
          System.out.println("start driver");
        }

    @Test
    public void login() {
    ...
    }

I read previous posts about this error and did:
1. Use my testng.xml as template in project properties
2. Right click testng.xml->run as testng suite
3. Select my .java test file and right click->run as testng test

But still get this error, could anyone provide kindly help? Thank you!




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2