Skip to content

Result model: Add message to keywords and control structures and remove doc from controls #4883

Closed

Description

@pekkaklarck

Currently some control structures in the result model have a doc attribute that's represented in output.xml as a <doc> element. This attribute is used for storing information about removing or flattening items using --flattenkeywords and --removekeywords options. It's a rather strange attribute because it's not possible to set documentation for control structures in data. It's also also inconsistent that only some of the control structures have it.

On the other hand, control structures don't have a message attribute that would contain their possible failure message, they only have status. Keywords have in practice don't have message either. They do have the attribute, it is only used with teardowns to make possible to see the error message if a suite teardown fails.

To fix the above issues, we have decided to do the following:

  • Add message to all keywords and control structures and always store the possible failure message in it.
  • Use message also for storing information about flattening or removing items.
  • Remove doc from control structures.

The main benefit of these changes is making the result model simpler and more consistent. It is important in general, but it gets even more important now that we are adding JSON serialization support to it (#4847) and that format will likely be used also by external tools.

The doc attribute that control structures currently have won't be directly removed, but it will be deprecated as part of #4846. Old output.xml files with possible <doc> elements with control structures will still be supported. Whatever content <doc> contains will be added to message.

Activity

  1. added this to the v7.0 milestone on Oct 4, 2023
  2. self-assigned this
    on Oct 4, 2023
  3. pekkaklarck commented on Oct 4, 2023

    @pekkaklarck
    MemberAuthor

    Although there are changes to output.xml, this issue shouldn't cause backwards compatibility issues.

    We don't anymore write <doc> elements with control structures, but it was earlier written only if items actually had something in doc and thus tools processing outputs couldn't expect it to be present. It's actually more likely that some tools could have been confused if such a rare element would be there.

    The new message attribute is written as a content of the <status> element. The element has existed with all items already earlier and has also had content with tests and suites (and keywords used as teardowns), so tools ought to handle it just fine.

  4. pekkaklarck commented on Oct 4, 2023

    @pekkaklarck
    MemberAuthor

    Although there shouldn't be direct backwards compatibility issues, output.xml size will grow because now failure messages are stored with all keywords and control structures, not only with tests. We don't expect the change to be noticeable unless there are big number of failures. If this causes issues in practice, we can consider making it configurable to store messages to output.xml. Even without such configuration, a simple pre-Rebot modifier with following content can clear all messages:

    def start_body_item(self, item):
        item.message = ''
  5. pekkaklarck commented on Oct 4, 2023

    @pekkaklarck
    MemberAuthor

    The most visible change is that the failure message is visible with all keywords and control structures also in the log file. We are not sure is that desirable and may decide to hide it still before RF 7.0. Feedback related to that is appreciated!

  6. pekkaklarck commented on Oct 4, 2023

    @pekkaklarck
    MemberAuthor

    I guess the changes listed in the two comments above warrant adding backwards incompatible label to this issue anyway.

  7. pekkaklarck commented on Nov 3, 2023

    @pekkaklarck
    MemberAuthor

    Based on my experience with using the current development version of Robot for testing Robot itself, I feel that showing the error message with all keywords and control structures in the log file doesn't work too well. Especially with longer errors and deeper nested structures it makes finding the actually failed keyword harder.

    It would be easy to not include message in the log file even though they are in the result model, but then extra information we add to the message at least with --removekeywords and --flattenkeywords would be lost as well. With keywords we could use doc instead, but these options also work with control structures that don't have doc. Removing it was one of the main motivations of this issue and it doesn't make sense to add it back.

    A somewhat easy solution would be showing only the beginning of the error with keywords and control structures. We could either cut it when the JS model used by the log file is constructed or we could have some JavaScript code that hides the message and allows viewing it fully if needed. The latter solution would be nice, but it's also more work and because the full message is anyway visible where it actually occurred it's not that important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions