如何设置TestNG + Jenkins

时间:2014-09-03 17:31:05

标签: java maven jenkins testng jenkins-plugins

我正在使用Jenkins运行一些testNG测试,当构建完成后,我在最后收到以下消息:

[INFO] Build failures were ignored.
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/test-output/testng-result.xml
Did not find any matching files.
Finished: SUCCESS

我查看了Jenkins的工作区,并且没有名为test-output的文件夹,这里的问题是,如何告诉jenkins创建包含结果的文件夹?

如果需要,这是我的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>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 -->
    </properties>

    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8</version>
            <scope>test</scope>
        </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>
        <finalName>My Automated tests</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

由于

2 个答案:

答案 0 :(得分:0)

您需要在jenkins中添加构建后操作,以添加可在工作区中找到的testng-result.xml的相对路径。

答案 1 :(得分:0)

我建议您在Jenkins插件中使用HTML Report Publisher Plugin并配置您的报告,如下所示。这将允许您查看每个构建的报告。通过这种方式,您将能够以明智的方式存档所有testNG报告,也可以在作业级别上查看。安装此插件后,配置您的作业并添加POST-BUILD-STEP(以启用HTML REPORT PUBLISHER)并按照testNG报告的位置设置进行操作。如有任何问题,请参阅下面的屏幕截图并告诉我。希望这有帮助!

通常,您在此处生成的TestNG报告:

<Jenkins-Location>\jobs\<JOB_NAME>\workspace\target\html

enter image description here