我是 maven 和 testng 的新手,我遇到了一个问题:运行 Maven 测试时,我无法从套件 xml 文件中获取用于测试的参数。结果是跳过了这个测试:
-------------------------------------------------------------------------------
Test set: TestSuite
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.375 sec
我不知道为什么有人可以帮我解决这个问题我非常感谢
谢谢
这是我的主要测试:hTest.java
package demo;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class hTest {
@Parameters({"user"})
@Test
public void getUser(String user)
{
System.out.println("NAME= " + user);
}
}
这是我的套件 hTest.xml
<?xml version="1.0" encoding="UTF-8"?>
<suite name="hTest" verbose="3" parallel="false">
<test name="hTest">
<parameter name="user" value="Giao"/>
<classes>
<class name="demo.hTest"/>
</classes>
</test>
</suite>
这是我的 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>BnS</name>
<properties>
<test.suite.dir>test.suites</test.suite.dir>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.33.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.33.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${test.suite.dir}/hTest.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>