我可以获得机器人框架内测试用例步骤的统计信息吗? [英] Can I get statistics for test cases steps inside robot framework?

查看:35
本文介绍了我可以获得机器人框架内测试用例步骤的统计信息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

最好的问候,

Emna A.

解决方案

使用robot framework api我们可以获得TEST和KEYWORD Metrics

参考:

链接

API:

  • class robots.result.model.Keyword
  • class robots.result.model.Test

关键字指标代码:

# Keyword Metrics Code:(将以下代码段保存为python文件并执行)从 robots.api 导入 ExecutionResult,ResultVisitorresult = ExecutionResult('output.xml')result.configure(stat_config={'suite_stat_level': 2,'tag_stat_combine': 'tagANDanother'})类 KeywordMetrics(ResultVisitor):defvisit_keyword(self,kw):打印关键字名称:" + str(kw.name)打印关键字状态:" + str(kw.status)打印关键字开始时间:" + str(kw.starttime)打印"关键字结束时间:" + " " + str(kw.endtime)打印关键字经过时间(秒):" + " + str(kw.elapsedtime/float(1000))result.visit(KeywordMetrics())# 笔记:#visit_keyword() 返回用户定义的关键字# start_keyword() 返回所有关键字(库和用户定义的)

测试指标代码:

# 测试指标代码:(将以下代码段保存为 python 文件并执行)从 robots.api 导入 ExecutionResult,ResultVisitorresult = ExecutionResult('output.xml')result.configure(stat_config={'suite_stat_level': 2,'tag_stat_combine': 'tagANDanother'})类 TestMetrics(ResultVisitor):defvisit_test(self,test):打印测试名称:"+ str(test.name)打印测试状态:"+ str(test.status)打印测试开始时间:"+ str(test.starttime)打印 "测试结束时间:" + " " + str(test.endtime)打印测试经过时间(秒):" + " + str(test.elapsedtime/float(1000))result.visit(TestMetrics())

Robot framework Metrics 项目已实施,可通过仪表板视图以 HTML 格式显示指标结果.

亮点

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

机器人框架指标报告自述文件

In order to optimize time of execution, i create some test cases dependent from each other i want to get metrics and statistics not only for each testcase and testsuite. But also i want to generate statistics and metrics for each step. Is that possible ? PS : I'm using team city for continuous integration.

Best regards,

Emna A.

解决方案

Using robot framework api we can get TEST and KEYWORD Metrics

Reference:

Link

API:

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

Keyword Metrics Code:

# 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:

# 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 project is implemented to show metrics result in HTML format with dashboard view.

Highlights

  • Top 10 Tests Performance Bar Graph
  • Top 10 Keyword Performance Bar Graph
  • Pie Charts
  • Keywords and Test Metrics in Tabular format

Robot framework Metrics Report ReadMe.MD

这篇关于我可以获得机器人框架内测试用例步骤的统计信息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆