【问题标题】:Maven-postman-plugin: correct configuration for goal, surefire-mailMaven-postman-plugin:目标的正确配置,surefire-mail
【发布时间】:2015-01-23 21:52:54
【问题描述】:

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

但是,当我运行 surefire-mail 目标时,我只发送/接收一封包含 no 测试结果内容的电子邮件。我收到一封包含默认内容的电子邮件:“为 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]

【问题讨论】:

  • 这里是 mvn 日志:
  • [13:09:39][com.company.project:project-model] [INFO] 分析:sur​​efire 报告... [13:09:39][com.company.project:项目模型] [调试] --> F:\work\ff5c2f34c9fedec2\project-model\target\failsafe-reports\TEST-TestSuite.xml [13:09:40][com.company.project:project-model] [DEBUG] 找到 TestSuite:errors=0,skipped=0,failures=0,tests=6 [13:09:40][com.company.project:project-model] [DEBUG] 测试错误:0 [13:09 :40][com.company.project:project-model] [DEBUG] 测试已跳过:测试失败:0 测试总计:6] 评估常规条件 [错误 0]

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


【解决方案1】:

我使用了一种变体来生成报告数据的电子邮件。我放弃了 surefire-mail 目标并使用了 send-mail 目标,只是附加了由 failsafe 生成的 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-05
    • 2019-01-06
    • 2014-07-02
    • 2012-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多