有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Maven+Jenkins+Testng运行测试后构建失败

我对詹金斯进行了一系列测试,结果如下:

Tests run: 5, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:39 min
[INFO] Finished at: 2014-07-21T16:33:14-07:00
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project barcoAutomation: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Code\Maven\.\Maven\barcoAutomation\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[INFO] Build failures were ignored.
[Maven] $ cmd /c call C:\Windows\TEMP\hudson8319915807901667722.bat

好吧,有些事情告诉我:maven surefire plugin:2.16是这里的问题,所以这里是我的pom文件供检查:

<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>com.barco.automation</groupId>
    <artifactId>barcoAutomation</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>barcoAutomation</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <!-- added -->
        <!-- <suiteFile>src/test/resources/barcoColor.xml</suiteFile> <suiteFile>src/test/resources/GeneralSettings.xml</suiteFile> -->
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8</version>
        </dependency>
        <dependency>
            <groupId>org.uncommons</groupId>
            <artifactId>reportng</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.42.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.10-FINAL</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.10-FINAL</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <suiteXmlFiles>
                    <suiteXmlFile>src/test/resources/barcoGeneralSettings.xml</suiteXmlFile>
                        <!-- <suiteXmlFile>${suiteFile}</suiteXmlFile> -->
                    </suiteXmlFiles>
                    <!--<suiteXmlFile>src/test/resources/GeneralSettings.xml</suiteXmlFile> 
                        <suiteXmlFiles> <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile> 
                        <suiteXmlFile>src/test/resources/NewFile.xml</suiteXmlFile> <suiteXmlFile>src/test/resources/barcoColor.xml</suiteXmlFile> 
                        </suiteXmlFiles> -->
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/test/resources/</directory>
            </resource>
        </resources>
    </build>
</project>

我在maven repository中检查了插件,我看到的唯一区别是,我在插件标签中有插件,在网站上它在dependecy标签中

这里可能有什么错误

谢谢

注意:很抱歉出现纯文本,但我不知道如何在代码上添加颜色=/


共 (1) 个答案

  1. # 1 楼答案

    maven命令运行成功,但是您的5个测试中有一个失败

    Tests run: 5, Failures: 1, Errors: 0, Skipped: 0
    

    失败的测试将导致生成“失败”

    看看:

    C:\Code\Maven\.\Maven\barcoAutomation\target\surefire-reports
    

    看看哪个测试失败了,为什么失败了