Maven-postman-plugin:正确的目标配置,surefire-mail

时间:2015-01-23 21:52:54

标签: maven maven-surefire-plugin maven-failsafe-plugin

我有一段时间的鲸鱼让这个插件向我发送故障安全或万无一失的测试结果。发送邮件目标工作正常(但不能使用groovy进行条件发送)。我可以向我的邮件收件人发送一个附件。

但是,当我运行surefire-mail目标时,我只发送/接收一封包含 no 测试结果内容的电子邮件。我收到一封默认内容的电子邮件:“build for com.xxxx.yyyy:zzz-abc:1.1.0-SNAPSHOT已执行”。我从未见过这个目标的默认测试结果的示例。我假设它类似于在surefire文件夹中找到的emailable-report.html - 但不确定。

<execution>
    <id>send results</id>
    <phase>site</phase>
    <goals>
        <goal>surefire-mail</goal>
    </goals>
    <configuration>
        <subject>[TeamCity] Project A- Test Results</subject>
        <groovyCondition><![CDATA[errors == 0]]></groovyCondition>
        <surefireReportHtml>
            ${project.build.directory}/site/failsafe-report.html
        </surefireReportHtml>
        <testReportsDirectory>
            ${project.build.directory}/failsafe-reports
        </testReportsDirectory>
        <receivers>
            <receiver>first.last@company.com</receiver>
        </receivers>
    </configuration>
</execution>

我尝试使用和不使用surefireReportHtmltestReportsDirectory标记。我正在运行:mvn deploy site

以下是我的日志:

[13:09:39][com.company.project:project-model] [INFO] analyze: surefire reports...
[13:09:39][com.company.project:project-model] [DEBUG] -->F:\work\ff5c2f34c9fedec2\project-model\target\failsafe-reports\TEST-TestSuite‌​.xml 
[13:09:40][com.company.project:project-model] [DEBUG] found TestSuite: errors=0, skipped=0, failures=0, tests=6
[13:09:40][com.company.project:project-model] [DEBUG] test ERRORS: 0 
[13:09:40][com.company.project:project-model] [DEBUG] test SKIPPED: test FAILURES: 0 test TOTAL: 6 ] evaluating groovy condition [errors <= 0 || errors > 0]

1 个答案:

答案 0 :(得分:0)

我使用了一个变体来生成报告数据的电子邮件。我放弃了万无一失的邮件目标并使用了发送邮件目标,并附上了由failafe生成的emailable-report.html。

希望这有帮助。

     <plugin>
            <groupId>ch.fortysix</groupId>
            <artifactId>maven-postman-plugin</artifactId>
            <configuration>
                <failonerror>false</failonerror>
                <skip>${test.integration.notif.skip}</skip>
                <mailhost><your mail host subdomain></mailhost>
                <from><your email account id and mail server: eg: id@comcast.net></from>
                <receivers>
                    <receiver><email account id and mail server></receiver>
                </receivers>
            </configuration>
            <executions>
                <execution>
                    <id>send attached failsafe html results notification</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>send-mail</goal>
                    </goals>
                    <configuration>
                        <subject>[TeamCity] Integration Test Results</subject>
                        <htmlMessage>
                           <![CDATA[
                             <p>
                                 We have new integration test results for:
                                    build: ${project.groupId}:${project.artifactId}:${project.version}
                                    rev: ${build.vcs.number}

                                 See attached failsafe report.
                             </p>
                             <br>
                           ]]>
                        </htmlMessage>
                        <fileSets>
                            <fileSet>
                                <directory>${project.build.directory}/failsafe-reports</directory>
                                <includes>
                                    <include>**/emailable-report.html</include>
                                </includes>
                            </fileSet>
                        </fileSets>
                    </configuration>
                </execution>
            </executions>
        </plugin>