我有一个使用 TestNG 进行 Selenium WebDriver 测试的 Maven 项目。我想分组运行测试,这就是为什么在 pom 文件中添加 Surefire 插件很重要,这就是我添加到 pom 文件中的内容:
如果我在使用 maven 添加这些单词后运行我的项目(使用 testNG 仍然有效),我会在控制台中收到错误,并且 WebDriver 甚至无法打开。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test
(default-test) on project PORefactor: Execution default-test of goal
org.apache.maven.plugins:maven-surefire-plugin:2.15:test failed: There was an error in
the forked process.
还有:
[ERROR] Cannot find class in classpath: com.volnoboy.POImplementation
我尝试刷新和清理项目。我将项目移至另一台计算机,错误是相同的。网络连接良好。我该怎么办?
最佳答案
这是我的pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<!-- <groups>1</groups> -->
<suiteXmlFiles>
<suiteXmlFile>testSuites\testng1.xml</suiteXmlFile>
<suiteXmlFile>testSuites\testng1.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.15</version>
</plugin>
尝试使用该插件。
当然,你的 pom 中需要 testng 和 selenium 依赖项。
希望有帮助。
关于java - Maven 不使用 pom 中的 Surefire 插件构建项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18966914/