我可以获得机器人框架内测试用例步骤的统计信息吗?

Can I get statistics for test cases steps inside robot framework?

为了优化执行时间,我创建了一些相互依赖的测试用例我想不仅为每个测试用例和测试套件获取指标和统计信息。但我也想为每个步骤生成统计数据和指标。 那可能吗 ? PS : 我正在使用 team city 进行持续集成。

此致,

Emna A.

您可以使用很多工具来实现这一目标。通过 Robot Framework 的侦听器接口,或通过 post-测试输出的解释,制作您自己的也相对容易。

您可以使用 this tool to post-process an XML output and get statistics about each keyword. You may also want to complement it with this tool,它基本上可以生成完整的基准测试报告

使用机器人框架api我们可以获得测试和关键字指标

参考:

Link

API:

  • class robot.result.model.Keyword
  • class robot.result.model.Test

关键字指标代码:

# Keyword Metrics Code: (save following snippet as python file and execute)
from robot.api import ExecutionResult,ResultVisitor

result = ExecutionResult('output.xml')
result.configure(stat_config={'suite_stat_level': 2,
                              'tag_stat_combine': 'tagANDanother'})

class KeywordMetrics(ResultVisitor):

    def visit_keyword(self,kw):
        print "Keyword Name: " + str(kw.name) 
        print "Keyword Status: " + str(kw.status)
        print "Keyword Starttime: " + str(kw.starttime)
        print "Keyword Endtime: " + " " + str(kw.endtime)
        print "Keyword Elapsedtime (Sec): " + " " + str(kw.elapsedtime/float(1000))

result.visit(KeywordMetrics())

# Note:
# visit_keyword() returns userdefined keywords
# start_keyword() returns all the keywords (library and user defined)

测试指标代码:

# Test Metrics Code: (save following snippet as python file and execute)
from robot.api import ExecutionResult,ResultVisitor

result = ExecutionResult('output.xml')
result.configure(stat_config={'suite_stat_level': 2,
                              'tag_stat_combine': 'tagANDanother'})

class TestMetrics(ResultVisitor):

    def visit_test(self,test):
        print "Test Name: " + str(test.name) 
        print "Test Status: " + str(test.status)
        print "Test Starttime: " + str(test.starttime)
        print "Test Endtime: " + " " + str(test.endtime)
        print "Test Elapsedtime (Sec): " + " " + str(test.elapsedtime/float(1000))

result.visit(TestMetrics())

Robot framework Metrics 项目已实施以在仪表板视图中以 HTML 格式显示指标结果。

亮点

  • 前 10 个测试性能条形图
  • 前 10 个关键字效果条形图
  • 饼图
  • 表格格式的关键字和测试指标

Robot framework Metrics Report ReadMe.MD