【问题标题】:How to generate custom logs using rebot command?如何使用 rebot 命令生成自定义日志?
【发布时间】:2018-06-25 16:40:32
【问题描述】:

我正在使用机器人框架执行一组测试用例,如下所示:

pybot -o output1.xml -l log1.html -r report1.html  testsuite.robot

这将在我的目录中分别创建输出 xml 文件以及报告和日志文件。

现在,考虑上述套件中有 10 个测试用例,其中 8 个通过,2 个失败。我将使用以下命令重新运行这些测试用例:

pybot --rerunfailed  -o output2.xml -l log2.html -r report2.html  testsuite.robot

我将获得两个 xml,然后我想将它们合并并使用以下命令将最终的 xml 文件作为 output1.xml 以及新的日志和报告文件:

rebot --merge output1.xml output2.xml

我担心的是,这里我们得到了log.htmlreport.html。但是,除了这些默认文件,我可以使用我给出的任何名称获取我的自定义日志吗?

如下图

rebot --merge output1.xml output2.xml -l Final_Log.html -r Final_Report.html

两个xml文件合并后如何获取自定义名称的日志?

【问题讨论】:

    标签: xml robotframework


    【解决方案1】:

    您不需要--merge

    如果您想将两个日志连接在一起,请使用此命令。

    rebot -N TwoCombinedTests --outputdir C:/Path/Where/You/Want/To/Save Test1.xml Test2.xml
    

    这将为您组合 2 个测试 xml,名称为 Test1Test2。在您使用--outputdir 选项和最终名称TwoCombinedTests 提供的路径中,这要归功于-N 命令。

    注意;当然,您必须在存储这些 xml 文件的当前目录中。如果使用终端,只需一个简单的cd /path/to/xmls 就足够了。

    编辑 - 在我的情况下,当我运行我的测试(大约 6 个机器人文件)时,它会生成每个文件中的 6 个(报告、日志输出),每个文件都有自己的自定义名称(测试名称以及构建/冲刺号。)然后,我会将这些名称放入 sprint 中并将它们全部合并。这是我用来让您了解 rebot 的含义的脚本示例(不要过度思考它是什么)

    # command to combine all the reports into one large report.
    os.system('rebot -N AllCombinedTests-' + SprintSlash + '-' + Build + ' '
              '--outputdir C:/AutomationLogs/' + Product + '/Combined/'
              + Version + Sprint + Build + " " + TotalXml)
    

    TotalXml 是找到的所有 XML 的字符串列表。

    编辑2:

    rebot --merge --name ExampleName original.xml merged.xml
    

    此rebot 命令将为您组合两个输出xml(original.xml 和merged.xml),名称为ExampleName

    从这里你将有一个很大的“输出 xml”,然后你可以再次运行 rebot 以从中生成报告/日志

    rebot -N NameThatYouWant ExampleName.xml
    

    这将使用您刚刚生成的 XML 以及名称“NameThatYouWant”

    有任何问题欢迎留言。

    【讨论】:

    • 感谢@Goralight。因此,您的意思是,-N 命令将合并两个 xml 文件并为您提供具有提及名称的新 xml。但是,日志文件呢?它是 log.html 还是 TowcombinedTests.html。请确认。
    • -N 命令将命名两个组合 output.xml 的子级。所以你给它XMLs test1 和test2。它将通读这些,将它们合并到您提供的目录中的最终报告/日志文件中为TwoCombinedTests.html
    • 如果您想将两个输出合并到另一个 xml 文件中,如果您想为其生成合并日志,这对我来说似乎是多余的。你最好跳过中间人并从你想要的 xmls 列表中生成一个组合日志/报告。不过,我现在会帮你检查。
    • @GenCoder 请看我的 Edit2 答案:)
    • 感谢您的帮助。它对我的执行帮助很大。再次感谢。
    【解决方案2】:

    我重新研究了这个问题。感谢 Goralight 激发了我获取自定义 xml、日志和报告文件的想法。

    开始吧。

    pybot -o output1.xml -l log1.html -r report1.html testsuite.robot

    pybot --rerunfailed  -o output2.xml -l log2.html -r report2.html  testsuite.robot
    

    在此之后,我必须合并这两个 xml 文件。我分别需要新的 xml 文件、日志文件和报告文件。因此,在 Gorlight 的结果和我进一步研究的帮助下,我得到了以下解决方案,我对此深信不疑。

    rebot --merge --output Final_output.xml -l Final_log.html -r  final_report.xml output1.xml output2.xml
    

    这给了我以下三个文件

    Final_output.xml、Final_log.html 和 final_report.xml

    最后这就是我想要的。否 这我与我的 Jenkins 报告生成器集成并填充了最终的通过/失败结果。

    非常感谢 Goralight 的帮助。

    【讨论】:

    • 虽然在我的情况下,它在我的 Jenkins 工作中工作得很好,但有点不同:'ipyrebot --rerunmerge --output F _output.xml -l F_log.html -r F_report.xml output-1。 xml output-2.xml'
    猜你喜欢
    • 1970-01-01
    • 2017-06-16
    • 2023-02-21
    • 1970-01-01
    • 2023-04-10
    • 2012-03-26
    • 1970-01-01
    • 1970-01-01
    • 2020-07-09
    相关资源
    最近更新 更多