从报告中删除日志信息并将报告保存在所需位置

时间:2015-02-11 20:48:54

标签: robotframework

我是机器人框架的新手,想知道我是否可以获得任何简单的自定义报告代码。我也很好回答我的问题。我查看了与报告相关的所有问题,但找不到我问题的具体答案。目前我的报告包含日志,想看看我是否可以从报告中删除日志信息并在特定位置保存报告。我只想在报告中获得PASS / FAIL信息。任何人都可以举例说明我如何克服这个问题?我还需要知道如何将报告保存在不同的位置。任何例子都会有所帮助。先感谢您。

1 个答案:

答案 0 :(得分:0)

有一个名为Rebot的工具,它是Robot Framework的一部分。

默认情况下,Robot Framework会创建XML报告。 Rebot会自动将XML报告转换为HTML报告。

您可以通过指定参数--outputdir来设置执行中输出文件的位置(从而为输出设置不同的基本目录)。

来自documentaiton:

可以使用绝对路径设置所有输出文件,在这种情况下,它们将创建到指定位置,但在其他情况下,路径被视为相对于输出目录。默认输出目录是从中开始执行的目录,但可以使用--outputdir(-d)选项进行更改。使用此选项设置的路径再次相对于执行目录,但自然也可以作为绝对路径给出。无论如何获得单个输出文件的路径,如果它不存在,则自动创建其父目录。 您可以自己致电Rebot来控制此转换。

您还可以在运行测试后运行Rebot,以便在其他位置创建新输出。

参见以下文档: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#post-processing-outputs

以下示例说明如何将HTML报告存储在其他位置,并仅包含部分数据:

rebot --include smoke --name Smoke_Tests c:\results\output.xml --outputdir c:\version1.0\reports

在上面的示例中,我们处理文件c:\ results \ output.xml,创建一个名为Smoke_Tests的新报告,其中仅包含带有标签smoke的测试并将其保存到输出文件夹c:\ version1.0 \ reports

此外,您还可以设置执行日志文件(HTML)的位置。

命令行选项--log(-l)确定创建日志文件的位置。

命令行选项--report(-r)确定创建报告文件的位置

删除日志行可能会有所不同。如果您运行rebot --help,您将获得以下选项:

 --removekeywords all|passed|for|wuks|name: *  Remove keyword data
                       from all generated outputs. Keywords containing
                       warnings are not removed except in `all` mode.
                       all:     remove data from all keywords
                       passed:  remove data only from keywords in passed
                                test cases and suites
                       for:     remove passed iterations from for loops
                       wuks:    remove all but the last failing keyword
                                inside `BuiltIn.Wait Until Keyword Succeeds`
                       name::  remove data from keywords that match
                                the given pattern. The pattern is matched
                                against the full name of the keyword (e.g.
                                'MyLib.Keyword', 'resource.Second Keyword'),
                                is case, space, and underscore insensitive,
                                and may contain `*` and `?` as wildcards.
                                Examples: --removekeywords name:Lib.HugeKw
                                          --removekeywords name:myresource.*
 --flattenkeywords for|foritem|name: *  Flattens matching keywords
                       in all generated outputs. Matching keywords get all
                       log messages from their child keywords and children
                       are discarded otherwise.
                       for:     flatten for loops fully
                       foritem: flatten individual for loop iterations
                       name::  flatten matched keywords using same
                                matching rules as with
                                `--removekeywords name:`