1

在此处输入图像描述在此处输入图像描述代码片段:

 @Test    // checking the login functionality 
 @Parameters({"username" , "password"})
 public void TpPortalLogin(String username, String password)
                                               throws InterruptedException, IOException
 {
    System.out.println("Page title before login: " +driver.getTitle());  
    System.out.println("username: "+username);  
    System.out.println( "password"+password);  

这是 testng.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="false">
    <test name="TpPortalLogin">
    <parameter name="browser" value="chrome"/>
    <parameter name="url" value="http://xyz.local/"/>
    <parameter name="username" value="somebody"/>
    <parameter name="password" value="something"/>
        <classes>
            <class name="com.parameterization.TestParameters" />
        </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

这是一个例外:

org.testng.TestNGException: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 251;
    Attribute "parallel" with value "none" must have a value from
                                           the list "false methods tests classes instances ".
  at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:325)
  at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:103)
  at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
  at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 251;
  Attribute "parallel" with value "none" must have a value from
                                         the list "false methods tests classes instances ".
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

任何想法将不胜感激。

在 testng.xml 中,没有参数“parallel”设置为“none”,因此异常会抱怨一个是没有意义的。

谢谢,

病死率。

4

1 回答 1

0

尝试使用TestNG对象从其他类运行 testng 类,如下例所示:-

public class TestNGRunTest {
   public static void main(String[] args) { 
      TestNG tng = new TestNG();
      List suites = Lists.newArrayList();
      suites.add("complete_path_of_testng.xml_file");
      tng.setTestSuites(suites);
      tng.run();
}

参考:
-TestNG 文档


请参阅setTestSuites部分

于 2016-06-30T05:45:32.480 回答