java - Maven 不使用 pom 中的 Surefire 插件构建项目

标签 java eclipse maven selenium testng

我有一个使用 TestNG 进行 Selenium WebDriver 测试的 Maven 项目。我想分组运行测试,这就是为什么在 pom 文件中添加 Surefire 插件很重要,这就是我添加到 pom 文件中的内容: enter image description here

如果我在使用 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/

相关文章:

java - 使用 HTML 5 和 servlet 的视频

c++ - 删除 cout 会导致段错误

windows - 在 Windows 上的 Makefile 中使用环境变量

java - Apache Beam 管道从 csv 文件读取、拆分、groupbyKey 并写入文本文件时出现 "IllegalStateException"错误。为什么?

java - HSQLDB - 更改/删除加密 key

java - 我是java初学者,谁能解释一下为什么我在这里得到 "InputmismatchExcetion"?

java - Android 以编程方式从 jar 中检索许可证信息

java RMI - 多个主机注册具有相同名称的对象

Java Maven OSGi 从文件系统动态加载 jar 并在运行时从中运行类方法

android - 我应该将 com.myapp.R 导入到我的 Activity 中吗?