Skip to content

Add a new keyword Repeat Keyword And Count Errors #5076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hpierre001 opened this issue Mar 8, 2024 · 2 comments
Closed

Add a new keyword Repeat Keyword And Count Errors #5076

hpierre001 opened this issue Mar 8, 2024 · 2 comments

Comments

@hpierre001
Copy link

It would work as Repeat Keyword but for test where a certain margin of errors is permited.

Another use case would be the need of statistics over failures.

If the number of errors is not needed, the following blok of code would be replace by:

Repeat Keyword    5 times    Run Keyword And Ignore Errors    My Keyword
Repeat Keyword And Count Errors    5 times    My Keyword

If the number of errors is needed, the following blok of code would be replace by:

${num_errors}    Set Variable    ${0}
FOR    ${counter}    IN RANGE    5
    ${status}    Run Keyword And Return Status    Fail
    IF    not ${status}
        ${num_errors}=    Evaluate    ${num_errors} + 1
    END
END
Log    ${num_errors}
${num_errors}    ${num_total}    Repeat Keyword And Count Errors    5 times    My Keyword

This keyword would also support repeat being given as timeout like Repeat Keyword, hence the ${num_total} returned.

@pekkaklarck
Copy link
Member

I consider this too specialized keyword to be added. If you just want to run a keyword certain amount of times so that you don't care about possible failures, you can use Repeat Keyword with Run Keyword And Ignore Errors as you already noted. Alternatively, you could use FOR IN RANGE or WHILE with limit in combination with TRY/EXCEPT/ELSE. The latter also makes it easy to keep count on failures if needed. More importantly, these structures make it easy to act differently on failures, something that a dedicated keyword wouldn't allow. Finally, I would like to avoid adding new Run Keyword variants and instead think about programmatic structures that support same functionality but are more flexible.

Although I'm not sold on the idea to add this keyword, I leave this issue open to see how others feel about it.

@pekkaklarck
Copy link
Member

Looking this again, I believe it's better to create a custom solution using the programmatic structures discussed in my previous comment

@pekkaklarck pekkaklarck closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants