我是maven和testng的新手 我遇到了一个问题:在运行Maven Test时,我无法从套件xml文件中获取参数。 结果是跳过了这个测试:
-------------------------------------------------------------------------------
Test set: TestSuite
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.375 sec
我不知道为什么 谁可以帮我这个事 我非常感激
谢谢
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>