我想创建一个输出文件(一个.CSV文件,作为一个例子),在该文件中存储从测试用例集执行得到的所有结果,在那里我可以指定事物,除了结果本身,例如我们测试用例标题,描述,执行日期/时间,测试用例持续时间等......
title, description, start datetime, duration (s), outcome
TC#1, My testcase #1, 2016/12/01 11:50:01, 64, BLOCKED
TC#2, My testcase #2, 2016/12/01 11:52:23, 70, PASSED
TC#3, My testcase #3, 2016/12/01 11:53:45, 90, FAILED
...
以前有人这样做过吗?
任何有关它的反馈都将不胜感激。
此致
答案 0 :(得分:1)
您可以使用-r选项运行run任务,即pysys.py run -r(查看所有选项的列表,使用pysys.py run -h)。 -r选项允许您根据pysysproject.xml文件中定义的编写器记录测试的输出。示例项目附带的此文件具有以下定义的;
<writers>
<writer classname="XMLResultsWriter" module="pysys.writer" file="testsummary-%Y%m%d%H%M%S.xml">
<!--
Set properties on the XML test output writer class. The available properties that
can be set are the stylesheet location, whether to use file URLs in all references
to resources on the local disk, and the directory to write the output file (defaults
to the current working directory). Note that Mozilla Firefox requires the stylesheet
to be located next to the XML file when loading the file, and all references to local
resources must be as file URLs. Internet Explorer and Chrome can load the stylesheet
from any location on the local disk, but cannot load resources when referenced by a
file URL.
<property name="outputDir" value="${rootdir}"/>
<property name="stylesheet" value="./pysys-log.xsl"/>
<property name="useFileURL" value="true"/>
-->
</writer>
<!--
Add in the test results writer if straight text output is required
<writer classname="TextResultsWriter" module="pysys.writer" file="testsummary-%Y%m%d%H%M%S.log">
<property name="outputDir" value="${rootdir}"/>
</writer>
-->
<!--
Add in the JUnit results writer if output in the Apache Ant JUnit XML format is required. Use the
outputDir property to define the output directory for the JUnit test summary files (the writer will
produce one file per test into this output directory). If not specified this defaults to the current
working directory.
<writer classname="JUnitXMLResultsWriter" module="pysys.writer">
<property name="outputDir" value="${rootdir}/target/pysys-reports"/>
</writer>
-->
</writers>
因此,在上面的示例中,您的测试输出将是xml。您可以拥有多个编写器,即取消注释TestResultsWriter,您将同时获得总结测试结果的xml和log输出。我目前没有CSV输出编写器,但您可以编写自己的编写器并将pysysproject.xml文件配置为指向该文件(如果您希望我添加到核心包中,也请输入功能请求) 。看一下pysys.writer包中的实现作为示例。