似乎我找不到使用TestNG和maven运行一个测试用例的方法,使用xml文件来参数化测试套件。
我可以使用以下命令在命令行中运行特定的测试套件:
mvn test -DsuiteXmlFile=path/to/resources/suite.xml
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.758 sec - in TestSuite
testHighUserLoginNoPass_Ok(suitesApi.TestApi) Time elapsed: 2.714 sec
testLowUserLoginNoPass_Error(suitesApi.TestApi) Time elapsed: 0.168 sec
testLowUserLoginNoPass_Error(suitesApi.TestApi) Time elapsed: 0.241 sec
testLowUserLoginNoPass_Error(suitesApi.TestApi) Time elapsed: 1.047 sec
testLowUserLoginNoPass_Error(suitesApi.TestApi) Time elapsed: 2.685 sec
testLowUserLoginNoPass_Error(suitesApi.TestApi) Time elapsed: 1.017 sec
testLowUserLoginNoPass_Error(suitesApi.TestApi) Time elapsed: 0.27 sec
Results :
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0
但是当我想用命令运行一个特定的测试用例时:
mvn test -DsuiteXmlFile=path/to/resources/suite.xml -Dtest=TestApi#testHighUserLoginNoPass_Ok
我收到错误,显示" TestApi#testHighUserLoginNoPass_Ok"没有获取xml套件文件中的参数
org.testng.TestNGException:
Parameter 'apk_id' is required by BeforeMethod on method beforeMethod but has not been marked @Optional or defined