无法执行目标org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test(默认测试)

时间:2019-12-05 11:42:40

标签: java maven jenkins maven-surefire-plugin

我在使用3.0.0-M4时遇到此问题。

我正在将jdk1.8.0_222与Maven 3.6.3。一起使用。

我什至尝试将maven 3.3.9与jdk1.8.0_222结合使用。我正面临着同样的问题。

操作系统:Ubuntu 18.0.4 Maven:3.6.3、3.6.0和3.3.9(尝试了这3个版本。但仍然有问题)Java版本:jdk1.8.0_222

有人可以帮我吗?我无法继续。

我的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>Expertus</groupId>
    <artifactId>Expertus</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ExpertusONE_4.5</name>
    <description>ExpertusONE_4.5</description>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>
        <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>4.1.1</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.1</version>
</dependency>
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>3.0.0-M4</version>
    <scope>test</scope>
</dependency>

    </dependencies>
    <packaging>war</packaging>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>

                </configuration>

            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
                <configuration>
                    <useSystemClassLoader>false</useSystemClassLoader>
                    <includes>
                        <include>CreateOrganization.java</include>
                    </includes>
                    <suiteXmlFiles>
                    <suiteXmlFile>/home/nivedab/Desktop/LocalCode/ExpertusONE_4.5/Learning_Suite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>


        </plugins>


    </build>


    <properties>
        <java.version>1.8.0_222</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

</project>

詹金斯的输出如下:

[错误]无法在项目Expertus上执行目标org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test(默认测试):

2 个答案:

答案 0 :(得分:0)

@Nivi 首先,规则是不要阅读人们在Google上写的所有内容,因为他们也会写不好的页面。正确的做法是从Apache Maven阅读原始教程。

您能否正确阅读本文档,并在页面https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html上看到所有出现的“ suiteXmlFiles” 字样,因此不应将您在POM中使用的这些配置参数组合在一起

接下来,您使用绝对路径会完全破坏Maven的所有功能。您的文件 Learning_Suite.xml 应该是模块基本目录的真实路径。因此,它是一个资源文件,其配置类似于文档中的<file>src/test/resources/suite.xml</file>https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html

此外,版本 1.8.0_222 是任何人都不应使用的版本。对于每个POM来说这都是足够透明的:

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

答案 1 :(得分:0)

<suiteXmlFile>src/test/resources/${suiteXmlFile}.xml</suiteXmlFile>

任何名称都将具有XML文件,测试将运行

相关问题