-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Feature] Add meta data to test case #2080
Comments
Why cannot you use tags for this purpose? You could use, for example, def get_test_id(tags):
for tag in tags:
if tag.startswith('id='):
return tag[3:]
raise ValueError('No id found!') *** Test Cases ***
Example
[Tags] id=123
${id} = Get Test Id ${TEST TAGS} |
Adding metadata to tests as name-value pairs has been proposed also earlier. The reason all proposals have been rejected include:
If you have use cases (1.) and are willing to provide a pull request (2.), we can think is the third issue alone severe enough to prevent this to be added. |
Hello. The meta data isnt needed for test selection, or reporting. As meta data isnt aimed to be reported on, Tags arent a good substitute, as they are reported on. So unless there is an option to not report the results of certain tags!? Cheers. |
There are --tagstatinclude and --tagstatexclude to configure tag statistics. Further tag related configuration is possible too if there are good use cases. |
Actually thinking about it exclude include tags wont work as there will be so many.. Reading a bit more the user guide I see there is possibility to add meta data to test suits. This enhancement is to add the same to test cases and expose via a get keyword. |
It's possible, for example, to exclude all id tags with Notice that even when tag stats are included/excluded, tests themselves will have those tags. If that's a problem, you could dynamically remove tags using I know that suites have metadata that is defined as name/value pairs and understand uou'd like tests to have them too. I don't think that's a good idea for the following reasons:
|
I knew this was proposed and rejected before, and searched old issues to see what we have commented earlier. The original issue with most comments is #688, but there's also #1039 as well as #1487 that seems to be submitted by you. Three individual people have asked this, so there clearly is demand for this feature. After reading the comments to the aforementioned issues, I still think it's better to use tags for this purpose. That's a functionality that already exists and that can be still improved. In my opinion the confusion added by a new feature that does pretty much the same thing isn't worth the possible benefits. It would be very interesting to see how well tags actually work in this kind of usage, though. I already showed simple code that can parse information from tags in my first comment and proposed using Notice that even if we would decide that tests should get metadata in addition to tags, it would still require someone needing it badly enough to implement it. If you think it is a very important feature, you could implement it yourself and compare results against just using tags. If results with metadata are much better and you have working code to implement them, it would be much easier to persuade us to merge a pull request. |
Ok thanks for the help on using tags... will get back on how it goes! Im not a python dev, so unlikely a merge request will come from me :-) Lets close the ticket! |
Cool, waiting to hear how tags work for you and is there something that we could enhance in them! Here's variant of the original library that parses the metadata from tags. This time it gets tags automatically from Robot, requires giving the name of the metadata you want as an argument, and handles matadata names case-insensitively: from robot.libraries.BuiltIn import BuiltIn
def get_test_metadata(name):
tags = BuiltIn().get_variable_value('${TEST TAGS}')
prefix = name.lower() + '='
for tag in tags:
if tag.lower().startswith(prefix):
return tag[len(prefix):]
raise ValueError("Metadata '%s' not found!" % name) Assuming you put that code to a file named *** Settings ***
Library TestMetadata.py
*** Test Cases ***
Example
[Tags] id=42 category=foo
${id} = Get Test Metadata ID
${cat} = Get Test Metadata category
Log Many ${id} ${cat} |
Hiya,
It would be good to add key/value meta data to a test case, e.g.
[META id=123, category=X]
The meta data isnt needed to select tests for execution, or needed in the output reports
However the meta data should be able to be accessed with keywords, e.g.
${ID}= Get Test Meta Data id
${CATEGORY}= Get Test Meta Data category
What this will be useful for is something like:
[META testlinkid=123 storyid=321]
And then to be able to access this meta data in the test case teardown, to pass to external libraries to report results in TestLink or even Zephr.
Thanks.
Clayton
The text was updated successfully, but these errors were encountered: