Error: Suite contains no tests

Error: Suite contains no tests

我的项目中有这个结构:

Tests
|__ Keywords
    |__ Keywords.robot
|__ Libs
|__ Scenarios
    |__ UI
        |__ TestScen.robot
|__ Variables
    |__ Variables.robot
|__ RunTest.py

这是TestScen.robot:

*** Settings ***
Library     Selenium2Library
Resource    ../../Variables/Variables.robot
*** Variables ***
*** Keywords ***
Test Login
    log to console      Test Login
    go to       ${url}
    Input Text      id=${uNameId}   ${uiUserName}
    Input Text      id=${passId}    ${uiPassword}
    Click Element   id=${signInId}
    log to console  YaaaaY!

这是RunTest.py:

import argparse
from robot import run
import os
import datetime
import sys


def get_args():
    parser = argparse.ArgumentParser(description='Robot Test Framework')

    parser.add_argument('--file',
                        metavar='f',
                        default="Scenarios",
                        help='get path of root scenario')

    parser.add_argument('--testSuite',
                        metavar='"scenario name"',
                        default=[],
                        nargs='*',
                        help='get names of test suits')

    parser.add_argument('--tags',
                        metavar='tag',
                        default=[],
                        nargs='*',
                        help='get name of tags')

    parser.add_argument('--testCases',
                        metavar='testCases',
                        default=[],
                        nargs='*',
                        help='get name of testCases')

    parser.add_argument('--skip',
                        metavar='skip',
                        default=["skip"],
                        nargs='*',
                        help='get name of skip testCases')

    args = parser.parse_args()

    return args

if __name__ == "__main__":
    dir_name = datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S')
    os.mkdir('Output/' + dir_name)
    args = get_args()
    run(
        args.file,
        report='Output/' + dir_name + '/report.html',
        log='Output/' + dir_name + '/log.html',
        output='Output/' + dir_name + '/output.xml',
        include=args.tags,
        test=args.testCases,
        exclude=args.skip,
        critical="Critical",
        suite=args.testSuite
    )

我运行RunTest.py这样:

python RunTest.py --file Scenarios/UI

这是输出:

[ ERROR ] Suite 'UI' contains no tests.
Try --help for usage information.

有什么问题?为什么框架无法识别我的场景文件??

您的文件没有测试用例。您有设置、变量和关键字,但没有测试用例。

我的猜测是您在 "Keywords" 下的内容实际上是一个测试用例。像这样更改 table 的标题:

*** Test cases ***
Test Login
    log to console      Test Login
    ...