多次运行一个测试用例并在测试统计下显示通过和失败计数 [英] Run a test case Multiple times and display the pass and fail count under test statistics

查看:32
本文介绍了多次运行一个测试用例并在测试统计下显示通过和失败计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何多次运行特定测试用例并在测试统计信息下显示通过和失败计数?

How to run a particular test case multiple times and display the pass and fail count under Test Statistics?

以下是我必须多次运行测试用例的当前代码.(测试用例用关键字实现并调用)

Below is the current code I have to run a test case multiple times. (The test case is implemented in a keyword and called)

*** Test Cases ***
Testcase
   repeat keyword    5    Run Keyword And Continue On Failure       Execute

*** Keywords ***
Execute
       log         Hello world!

使用pybot testcase.robot"从cmd运行代码

The code is run from cmd using "pybot testcase.robot"

此代码多次运行测试,但我没有在日志中获得最终通过/失败计数.我需要手动计算通过和失败的测试用例重复.

This code runs the test multiple times but I'm not getting the final pass/fail count in the logs. I need to manually count the pass and fail test case repetitions.

那么我应该做哪些修改来自动获取数据,也应该在日志的测试统计中看到.

So what modifications should I do to get the data automatically and should be seen in Test Statistics of the log also.

推荐答案

不要使用重复关键字",而是使用 For 循环.使用运行关键字并返回状态"而不是运行关键字并在失败时继续".

Instead of using "Repeat Keyword", use For loop. Use "Run Keyword And Return Status" instead of "Run Keyword And Continue On Failure ".

*** Test Cases ***
Test Me
    ${fail}=  Set Variable  0
    :FOR  ${index}  IN RANGE  5
    \  ${passed}=  Run Keyword and Return Status    Execute
    \  Continue For Loop If  ${passed}
    \  ${fail}=  ${fail} + 1
    ${success}=  Set Variable  5 - ${fail}
    Log Many   Success:  ${success}
    Log Many   fail:  ${fail}

这篇关于多次运行一个测试用例并在测试统计下显示通过和失败计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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