Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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
pekkaklarck opened this issue Oct 4, 2023 · 5 comments

Comments

@pekkaklarck
Copy link
Member

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.

@pekkaklarck
Copy link
Member Author

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.

@pekkaklarck
Copy link
Member Author

pekkaklarck commented Oct 4, 2023

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 = ''

@pekkaklarck
Copy link
Member Author

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!

@pekkaklarck
Copy link
Member Author

pekkaklarck commented Oct 4, 2023

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

pekkaklarck added a commit that referenced this issue Oct 7, 2023
Nowadays keywords and control structures have `message` (#4883). It
should not be set with BREAK, CONTINUE and RETURN, though.
@pekkaklarck
Copy link
Member Author

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.

pekkaklarck added a commit that referenced this issue Nov 6, 2023
Issue #4883 added `message` to keywords and control structures in the
result model and they were also added to the log file. With nested
structures, it is possible that multiple keywords or control
structures have the same message that is also shared by the test
case. This is somewhat annoying in general and especially problematic
with longer messages.

This commit removes writing normal keyword and control structure
messages to the log file. Only messages that are written are notes
about keywords being removed or flattened with `--remove-keywords` or
`--flatten-keywords`. These notes are now wrapped with `<span
class="robot-note"></span>` to make it possible to recognize them.

Issue #4931 proposes collapsing long messages in log and
report. If/when that's implemented, we can consider including also
keyword and control structure messages in the log file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant