robot根据【output.xm】产生【log.html】

https://www.cnblogs.com/apple2016/p/7525845.html

  1. cmd
rebot -d .  output.xml
  1. python
# coding:utf-8

from robot.api import ExecutionResult
from robot import rebot
from robot import rebot_cli
from robot import run_cli
import os



def parse_robot_results(xml_path):
    suite = ExecutionResult(xml_path).suite
    allTests = suite.statistics.critical
    print(allTests.total)  # 总测试条数
    print(allTests.passed)  # 通过的条数
    print(allTests.failed)  # 失败的条数


if __name__ == '__main__':
    # 统计信息
    # path = 'output.xml'
    # r = parse_robot_results(path)


    # 1 output.xml -> log.html
    # os.system(f'''cd {os.path.dirname(__file__)}&& rebot -d .  output.xml''')

    # 2 不能用
    # Run tests and return the return code.
    # rc = run_cli(['-d', os.path.dirname(__file__), os.path.join(os.path.dirname(os.path.realpath(__file__)), 'output.xml') ])

    # 3 能用 ,执行完还能继续执行下面的代码
    rebot('output.xml')

    # 4 能用,执行完退出,下面的代码不执行
    # rebot_cli(['-d', '.', 'output.xml'])

原文地址:https://www.cnblogs.com/amize/p/14921994.html