Skip to content

Programmatically re-running failed tests prevents subsequent Robot and Rebot usage in same process #2437

Closed

Description

@krizex

When we use RobotFramework.main to execute test suites, we get a output.xml result file, then we use RobotFramework.main and the output.xml to rerun the failed cases in the same process, we get the second result file, naming it output_rerun.xml. After that, we use rebot api to merge the output.xml and output_rerun.xml to one result file, naming output_all.xml. We find that output_all.xml just contains the execution result of the failed cases.

So we checked the source code of robotframework, and we found the error code in robot/conf/settings.py:83
image

We found that code will change the default value of the items of _BaseSettings._cli_opts.
The root cause of this issue is self['TestNames'] and _BaseSettings._cli_opts['TestNames'][1] reference the same list, when execute self['TestNames'] += self['ReRunFailed'], equal to change the value of _BaseSettings._cli_opts['TestNames'][1]

Activity

  1. added a commit that references this issue on Aug 31, 2016
  2. added this to the 3.0.1 milestone on Aug 31, 2016
  3. pekkaklarck commented on Aug 31, 2016

    @pekkaklarck
    Member

    This looks nasty. I want to reproduce this myself before merging the PR. I'll make sure this is included in RF 3.0.1, but it may still take a little time before I have a possibility to concentrate on that release.

  4. krizex commented on Sep 1, 2016

    @krizex
    ContributorAuthor

    I have added some UT in the PR, you can use it as a reference for your reproducing.

  5. Direl commented on Sep 20, 2016

    @Direl

    I too have had this problem when calling both robot.run and robot.rebot from the same Python program. The attached files demonstrate this problem. Python (version 2.7) script test2.py runs flip.robot which always passes the first test case run and fails the second. The outputs from the first run are out1.xml and log1.html. It then reruns the failed tests in out1.xml producing outputs out2.xml and log2.html. Finally it tries to merge out1.xml and out2.xml into log3.html. However log3.html only contains the result of the rerun tests not all of the tests.

    The suggested fix for this bug in robot/conf/settings.py also solves my problem.

    Friday.zip

  6. pekkaklarck commented on Sep 20, 2016

    @pekkaklarck
    Member

    Seems to be a more common problem. Updated priority accordingly.

  7. self-assigned this
    on Sep 22, 2016
  8. pekkaklarck commented on Sep 22, 2016

    @pekkaklarck
    Member

    Looking at the added unit tests in PR #2438, I noticed there's a similar test added when a similar issue #881 was fixed five years ago. Strange that nobody had encountered this variation earlier.

    UPDATE: This problem seems to only occur when using --rerunfailed option. It updates TestNames setting inplace while others seem to replace values altogether. This would explain why nobody has encountered this before at least before --rerunfailed existed. If this is the only option causing the issue, I'll update the title of this issue accordingly.

  9. changed the title [-]Options' default value of RobotSettings and RebotSettings should not be changed when running[/-] [+]Programmatically re-running failed tests prevents subsequent Robot and Rebot usage in same process[/+] on Sep 22, 2016
  10. pekkaklarck commented on Sep 22, 2016

    @pekkaklarck
    Member

    Thanks a lot for the bug report and PR @krizex! The PR was merged as 9f1490e and I did some enhancements to it in c45a051. This issue is done.

  11. krizex commented on Sep 23, 2016

    @krizex
    ContributorAuthor

    UPDATE: This problem seems to only occur when using --rerunfailed option. It updates TestNames setting inplace while others seem to replace values altogether. This would explain why nobody has encountered this before at least before --rerunfailed existed. If this is the only option causing the issue, I'll update the title of this issue accordingly.

    @pekkaklarck Yes, you figure out the root cause. I think it's better to separate the instance's attributes and class's attributes, so I copy the value from class to instance as the PR did rather than just modify the code of updating TestNames

    Thanks for your enhancements.

  12. pekkaklarck commented on Sep 23, 2016

    @pekkaklarck
    Member

    @krizex: I agree it's better to avoid all potential problems with mutable objects rather than just fixing the issue with --rerunfailed updating TestNames. I wanted anyway to change the issue title to match the actual problem.

  13. krizex commented on Sep 23, 2016

    @krizex
    ContributorAuthor

    I am agree with you, the title you changed is ok.

    在 2016年9月23日,16:31,Pekka Klärck [email protected] 写道:

    @krizex: I agree it's better to avoid all potential problems with mutable objects rather than just fixing the issue with --rerunfailed updating TestNames. I wanted anyway to change the issue title to match the actual problem.

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHub, or mute the thread.

  14. added theissue type on Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions