Excluding tests with multiple tags...

9,903 views
Skip to first unread message

bm.gur...@gmail.com

unread,
Oct 28, 2013, 10:58:15 AM10/28/13
to robotframe...@googlegroups.com
Hi,

I want to exclude tests based on tags using option "exclude". My requirement is below.

Analogy:
Suppose, I have bunch of test cases with Tags have "Tag1, Tag2, Tag3....Tag10".

Now my requirement is whichever test cases having "Tag1, Tag3, Tag5, Tag7", should be excluded from the execution.

I have tried with below command...

"Pybot -i Tag* -e Tage1ANDTag3ANDTag5ANDTag7 Exmple.txt".

In this case test cases which have all "Tag1, Tag3, Tag5, Tag7" will exclude from test, since "AND" combination.

In real time all the test cases may not contain all tags, i.e., Testcase 1 contains Tag1, and TestCase 2 contains Tag3. So in this case above command will not exclude these tests, even though I asked to exclude. since above "exclude Options" will not match (AND).

So in order solve this problem we should have "OR" functions.

However I have raised "Enhancement" request in Robot Frame work page.

But I would appreciate if any body has different Ideas other than "OR" operator requirement.... and do let me know.

Thanks,
Guruswamy

Kevin O.

unread,
Oct 28, 2013, 11:14:28 AM10/28/13
to robotframe...@googlegroups.com
The exclude tag can be repeated (notice the asterisk in the output of --help), essentially ORing the values.
Have you tried:

bm.gur...@gmail.com

unread,
Oct 28, 2013, 12:21:18 PM10/28/13
to robotframe...@googlegroups.com
Thanks Kevin,

I know this and I have tried..but it will increase my run command length..looking more generic way it it has..

Thanks..

Kevin O.

unread,
Oct 28, 2013, 1:51:56 PM10/28/13
to robotframe...@googlegroups.com
So if you knew it could be done that why, why didn't you say so?
You are asking the RF team to introduce code that could break peoples scripts to save a few characters.
What if I had a test tagged LINUXPORT?
-e LINUXPORT
would essentially become
-e LINUXP -e T
Adding the OR logic you are suggesting would break people's scripts and save a measly 2 characters per extra tag excluded.

bm.gur...@gmail.com

unread,
Oct 29, 2013, 4:17:59 AM10/29/13
to robotframe...@googlegroups.com
Hi Kevin..

Thanks for the inputs..

The problem you have mentioned it is already have in existing implementation.

EX:
-e PANDA or -i PANDA
-e SMOKENOTE or -i SMOKENOTE

So in this case test designer has to use sense while naming the tag. I don't see here any implementation specific issue. 

I think "OR" is a good option to had..it will give good combinations to user..

However I have given reason for requirement. Suppose if RBF development team thinks it has any implementation specific issue..then they can reject this request.


Tatu Aalto

unread,
Oct 29, 2013, 3:41:27 PM10/29/13
to robotframe...@googlegroups.com
Ugh

For a quick workaround, you can build your own runner script quite
easily. If you are a python person, here is an example you how to use
python argparse [1] [2] and RF public API [3] run module [4]. Fell free
to extend, when your requirements grow.

import argparse
from robot import run

parser = argparse.ArgumentParser()
parser.add_argument("test_suite",
help="path to test suite")
parser.add_argument("-i", "--include",
help="Selects the test cases by tag. It is possible
to use AND as a separator for tags.
Example run_script.py test_with_tags.txt -i 1AND2")
args = parser.parse_args()

if args.include:
tags = args.include.split("AND")
run(args.test_suite, include=tags)
else:
run(args.test_suite)

-Tatu
[1] http://docs.python.org/2/library/argparse.html
[2] http://docs.python.org/2/howto/argparse.html
[3] https://robot-framework.readthedocs.org/en/2.8.1/
[4]
https://robot-framework.readthedocs.org/en/2.8.1/autodoc/robot.html#module-robot.run
> --
> You received this message because you are subscribed to the Google
> Groups "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to robotframework-u...@googlegroups.com.
> To post to this group, send email to
> robotframe...@googlegroups.com.
> Visit this group at http://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/groups/opt_out.

command_line_parser.zip

Jerry S.

unread,
Feb 13, 2014, 3:56:50 PM2/13/14
to robotframe...@googlegroups.com
If you really need to save a few characters in the commandline, learn to use argument files.  The change you requested here caused me to have to edit over 15,000 testcases and change tags.  We use argument files to keep commandlines short and understandable.

jer

Pekka Klärck

unread,
Feb 13, 2014, 6:26:47 PM2/13/14
to Jerry Schneider, robotframework-users

Jerry, if you want to blame someone please blame me for adding the feature, not others for requesting it. The reason we added OR pattern in RF 2.8.4 was that it was needed in the new search in report that a team at NSN, the corporate sponsor, requested. It had somewhat high priority.

Notice also that there isn't any need for you to change your tests. Tag patterns are case-insensitive, which means that, for example, '--include core' matches test also if it has tag 'CORE'. It's just that if you use '--include CORE', Robot nowadays thinks you want to match tests with tag 'c' or 'e'. In other words, it ought to be enough for you to update start-up scripts to use lowercase patters.

Sent from my mobile.

--

Jerry Schneider

unread,
Feb 13, 2014, 6:36:38 PM2/13/14
to Pekka Klärck, robotframework-users
Pekka,

Sorry I didn't mean to sound like I was blaming anyone.  For us, changing the testcases was needed to stay within coding standards we use internally.  We strive for a very high consistency and using "CORE-" some places and then requiring users to use "core-" in a different place violated that.  For me it was an easy change using find and sed.  It actually took much longer to verify the change than to actually do the change. :)  Point being is that we had to touch over 15,000 testcases.  You are right in that it is our own standard requiring this, not RF.

We also heavily use argument files to keep commandlines understandable and short.  Those argument files can be documented with comments and are very clear.  If anyone needs examples, please let me know, I would be happy to share examples and explain them if needed.

Again, I do apologize for coming on so strong and I was not trying to blame anyone.

jer
-- 
Linux registered user #475536
Ubuntu registered user #28583

Pekka Klärck

unread,
Feb 13, 2014, 6:47:22 PM2/13/14
to Jerry Schneider, robotframework-users

Ok. I just wanted to make sure nobody thinks they need to think about all consequences when requesting new features.

Good to hear you were able to update your data easily with some find and sed magic. 'find ... | xargs sed -i ...' is a mighty tool.

Sent from my mobile.

Reply all
Reply to author
Forward
0 new messages