• 【robotframework】Robot Framework Lint介绍


     

    今天给组内成员介绍了一下rflint,结合在线帮助总结如下文档:

    总体介绍

    Robot Framework Lint工具(robotframework-lint)是一个针对robot framework文本文件的静态分析工具。主要基于工具定义的一系列规则进行测试用例文本的静态分析。

    安装说明

    推荐使用pip进行安装:

    $ pip install --upgrade robotframework-lint

    安装成功后,package名字为rflint,执行命令也是rflint。

    运行rflint

    通过命令rflint来运行或者通过python加上-m参数来运行rflint模块。参数主要是一个或者多个待分析的文件。rflint帮助信息如下:

    usage: python -m rflint [-h] [--error RULENAME] [--ignore RULENAME] [--warning RULENAME] [--list] [--describe] [--no-filenames] [--format FORMAT] [--version] [--verbose]

                            [--configure CONFIGURE] [--recursive] [--rulefile RULEFILE] [--argumentfile ARGUMENTFILE]

                            ...

     

    A static analyzer for robot framework plain text files.

     

    positional arguments:

      file

     

    optional arguments:

      -h, --help            show this help message and exit

      --error RULENAME, -e RULENAME

                            Assign a severity of ERROR to the given RULENAME

      --ignore RULENAME, -i RULENAME

                            Ignore the given RULENAME

      --warning RULENAME, -w RULENAME

                            Assign a severity of WARNING for the given RULENAME

      --list, -l            show a list of known rules and exit

      --describe, -d        describe the given rules

      --no-filenames        suppress the printing of filenames

      --format FORMAT, -f FORMAT

                            Define the output format

      --version             Display version number and exit

      --verbose, -v         Give verbose output

      --configure CONFIGURE, -c CONFIGURE

                            Configure a rule

      --recursive, -r       Recursively scan subfolders in a directory

      --rulefile RULEFILE, -R RULEFILE

                            import additional rules from the given RULEFILE

      --argumentfile ARGUMENTFILE, -A ARGUMENTFILE

                            read arguments from the given file

     

    You can use 'all' in place of RULENAME to refer to all rules.

     

    For example: '--ignore all --warn DuplicateTestNames' will ignore all

    rules except DuplicateTestNames.

     

    FORMAT is a string that performs a substitution on the following

    patterns: {severity}, {linenumber}, {char}, {message}, and {rulename}.

     

    For example: --format 'line: {linenumber}: message: {message}'.

     

    ARGUMENTFILE is a filename with contents that match the format of

    standard robot framework argument files

     

    If you give a directory as an argument, all files in the directory

    with the suffix .txt, .robot, .resource, or .tsv will be processed.

    With the --recursive option, subfolders within the directory will

    also be processed.

    自定义规则

    每个规则都是一个Python类。下面是一个检查测试套内是否存在重复测试用例的样例:

     

     详细信息参见:https://github.com/boakley/robotframework-lint/wiki

    参数文件

    像robot framework一样,rflint也支持参数文件。我们可以将不同的参数写在同一个文件的不同行里面,然后通过命令行参数-A或者--argument-file来指定参数文件。

    参数文件是创建一系列适用于当前用例文件的规则以及配置规则的一种便捷的方式。

    例子

    基本用法

    $ rflint myTestSuite.robot

    使用如下命令来列出所有的内建规则:

    $ rflint –list

    如果想查看每个规则的解释,可以加上--verbose选项:

    $ rflint --list –verbose

    有些规则是可以配置的。例如,如果我们想配置规则”LineTooLong”为标记长度超过80个字符的行(默认100),可以用configure选项来更改默认值:

    $ rflint --configure LineTooLong:80 myTestSuite.robot

    您可以禁用任何规则,或使用--warning,-error和--ignore选项将其配置为警告或错误。例如,要忽略LineTooLong规则,可以执行以下操作:

    $ rflint --ignore LineTooLong myTestSuite.robot

    要查看所有命令行选项的列表,请使用--help选项:

    $ python -m rflint –help

    样例输出:

     

     显示了两个W(Warning),第一个警告是第30行长度超过100;第二个警告是第二行期望包含测试套文档,但是没有监测到。

  • 相关阅读:
    c语言 423输出直角在右上角的等腰直角三角形
    R语言中aggregate函数进行整合数据
    c语言 425输出向下的金字塔
    C语言 423 输出直角在左上角的等腰直角三角形
    c语言 422 显示出一个横向较长的长方形
    R语言中subset函数
    R语言中for、while、if else、switch语句
    c语言 424 输出金字塔性状
    R语言中apply函数
    WinCE文件基本操作
  • 原文地址:https://www.cnblogs.com/frankzs/p/14554300.html
Copyright © 2020-2023  润新知