我正在执行
testng.xml
到maven test from
command prompt
。
它可以很好地使用单个类调用,而不扩展任何其他类。但是当通过定义扩展类来调用它时,它不执行任何操作。生成成功,但没有执行任何操作。
示例代码:
public class testdemo02 extends demo01{
@课前
在emo()之前的公共void
{
system.out.println(“演示前”);
}
@测试
public void testdemo()。
{
system.out.println(“欢迎”);
WebDriver驱动程序=new chromedriver();
driver.get(“http://google.com”);
driver.close();
}
}
pom.xml:-
插件
<插件>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>Maven Surefire插件</artifactid>
<版本>2.22.0</version>
<配置>
<suitexml文件>
<suitexmlfile>$suitexmlfile</suitexmlfile>
</suitexml文件>
</configuration>
</plugin>
</plugins>
testng.xml:-
<?xml version=“1.0”encoding=“utf-8”?gt;
&!doctype套件系统“http://testng.org/testng-1.0.dtd”>
<suite name=“suite”>
<test thread count=“5”name=“test”>
<类>
<class name=“other.testedemo02”/>
</classes>
</test><!--测试-->
</suite><!--套房——>
命令:-
mvn test-dsurefire.suitexmlfiles=“/run xml scripts/testng.xml”
对于maven surefire plugin有什么需要改进的吗?如果不扩展类,它就会工作。
样本代码:
public class testdemo02 extends demo01 {
@BeforeClass
public void beforeDemo()
{
System.out.println("Before Demo");
}
@Test
public void testDemo()
{
System.out.println("Welcome");
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");
driver.close();
}
}
pom.xml:-
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
测试.xml:-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
<classes>
<class name="other.testdemo02"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
命令:
mvn test -Dsurefire.suiteXmlFiles="./Run XML Scripts/testng.xml"
有什么需要改进的吗Maven Surefire插件?如果不扩展类,它就会工作。