由于报告未显示,如何通过电子邮件发送 junit 报告

How to send junit report via email as report doesn't display

我在本地有一个 Junit HTML 报告,它是通过 ANT 构建的:

现在我遇到的问题是,如果我尝试通过仅发送 index.html 来附加此报告,它将显示:

我想知道如何通过电子邮件发送上述报告,以便每个人都能看到 html 报告。我只想发index.html我不想发给大家相应的文件

构建此报告的xml代码如下(我在真实文件中删除了一些不是xxx的东西):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto generated file.
          Any modifications will be overwritten.
          To include a user specific buildfile here, simply create one in the same
          directory with the processing instruction <?eclipse.ant.import?>
          as the first entry and export the buildfile again. -->

<project basedir="." default="Test_Report" name="Test_Report">


<target name="xxx_SoapUI">
 <exec dir="." executable="C:\Program Files\SmartBear\SoapUI-5.3.0\bin\testrunner.bat">
 <arg line="-r -j -f 'D:\xxx\xxx' 'D:\xxx).xml'"></arg>
</exec>
</target>

    <target name="xxx_SoapUI">
 <exec dir="." executable="C:\Program Files\SmartBear\SoapUI-5.3.0\bin\testrunner.bat">
 <arg line="-r -j -f 'D:\xxx\xxx' 'D:\xxx).xml'"></arg>
</exec>
</target>

    <target name="xxx_SoapUI">
 <exec dir="." executable="C:\Program Files\SmartBear\SoapUI-5.3.0\bin\testrunner.bat">
 <arg line="-r -j -f 'D:\xxx\xxx' 'D:\xxx).xml'"></arg>
</exec>
</target>


</project>

format="frames"属性通常为框架和样式表生成单独的文件。如 task documentation 中所述,您可以将值设置为 noframes,Ant 将在单个 HTML:

中生成报告

The noframes format does not use redirecting and generates one file called junit-noframes.html.

如果您需要自定义用于生成报告的 XSL,您可以使用 styledir 属性覆盖它(注意文件必须命名为 junit-noframes.xsl)。默认的XSL嵌入在Ant源码中,可以查看here.

这是替代方法。

在这种方法中,不要使用任何测试结果的附件。相反,将结果托管在 tomcat 或 WebDAV 等容器中。

这里是 tomcat 的例子(对于 WebDAV 也应该是类似的东西):

  • 安装tomcat
  • 在 TOMCAT_HOME\webapps 目录下创建目录 reports 并确保 tomcat 已启动。
  • 使用当前 ant 目标生成报告后,创建新目标以将当前报告移动到 TOMCAT_HOME\webapps\reports\<timestamp>
  • 在电子邮件中发送报告 link。报告 link 可能是 http://<hostname>:<port>/reports/<timestamp>/index.html

这样,每个人都可以在线访问报告。