繁体   English   中英

未能在项目上执行目标 org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test)

[英]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project

我正在使用 JAVA、MAVEN 和 TESTNG 的组合从事测试自动化项目。 测试用例在本地环境中运行良好,但 JENKINS 构建遇到以下错误。 不确定环境之间缺少什么。

我已经按照互联网的指导更改了 POM 中的一些配置。 没有任何效果

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default- 
  test) on project Getter_Web_UI: There are test failures/ 
     [ERROR] Please refer to /var/lib/jenkins/workspace/testING/target/surefire-reports for the 
    individual test results.
        [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and 
         [date].dumpstream.
       [ERROR] There was an error in the forked process
         [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
   [ERROR]  at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:733)
    [ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:305)
    [ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:265)
    [ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1314)

POM.XML

enter code here<?xml version="1.0" encoding="UTF-8"?>

4.0.0

<groupId>org.TESTING</groupId>
<artifactId>TESTING</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <forkCount>3</forkCount>
                    <reuseForks>true</reuseForks>
                    <useSystemClassLoader>false</useSystemClassLoader>
                    <useManifestOnlyJar>false</useManifestOnlyJar>
                    <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
           </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.14.0</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
    </dependency>
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.6.1</version>
    </dependency>
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>4.0.6</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.30</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.30</version>
        <scope>test</scope>
    </dependency>
</dependencies>

这些步骤帮助我解决了

  1. 从 jdk16 Java jdk 8 或 11 更新到支持 jenkins 构建运行。

  2. 插件管理标签正确对齐。

     <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M5</version> <configuration> <includes> <include>Sample.java</include> </includes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>8</source> <target>8</target> </configuration> </plugin> </plugins>

现在肯定能够选择测试并运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM