Run a test case Multiple times and display the pass and fail count under test statistics

a 夏天 提交于 2019-12-21 02:33:11

问题


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!

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.


回答1:


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}


来源:https://stackoverflow.com/questions/31311941/run-a-test-case-multiple-times-and-display-the-pass-and-fail-count-under-test-st

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!