Using Remove Tags and Force Tags. Is it possible?

1,159 views
Skip to first unread message

Joaquim P

unread,
Aug 31, 2011, 7:20:12 AM8/31/11
to robotframework-users
Hi,

I'm using Force tags and setting a tag for all tests: coresmoke tag.
Then, in Suite Setup, I'm removing that tag under certain
circumstances using Remove Tags Keyword:

Run Keyword Unless '${ADAPT_DEPLOY_STATUS}' == '0' Remove Tags
coresmoke

In Robot Test report, I can see for the test that the tag was removed:
Tags: ATDD, bring_up, Not_Critical, PSI-5, smoke, US_28014, US_28016,
US_28017, US_28019

But the test is executed anyway.

Can I do that, i.e. having a tag in Force Tags and then removing it
using Remove Tags in Suite Setup?
If not, if I add explicitly the tag to the test, can I remove the tag
using Remove Tags in Suite Setup so the test is not run.
Or do I need to remove the tag in Test Setup and not Suite Setup?

Note: Robot is called using jybot --include "coresmoke"

Thanks,
Joaquim

Fionna O'Sullivan

unread,
Aug 31, 2011, 7:50:03 AM8/31/11
to jp.cai...@gmail.com, robotframework-users
I was trying to do something similar recently, except in test setup instead of suite setup, and had the same problem - the tag is set or removed correctly, but the test is still executed. My guess is that the list of tests to be executed is set up sometime before suite setup is executed, and remains fixed, and dynamically changing tags is for reporting instead of execution - I worked around by changing the tag and setting it as noncritical instead of exclude, but that probably doesn't make sense in your situation.

BR,
Fionna


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.




--

Bad habits are like a comfortable bed, easy to get into, but hard to get out of.
~Anonymous

Joaquim P

unread,
Aug 31, 2011, 9:14:49 AM8/31/11
to robotframework-users
Hi,
Thanks for your help.
In this case, that solution won't work.
I'll try to dig a bit in Robot APIs to see if there is some way to
achieve same purpose.
Last option would be to add a run keyword unless in each test but it's
not very elegant.

Br,
Joaquim

Pekka Klärck

unread,
Sep 2, 2011, 6:47:24 AM9/2/11
to jp.cai...@gmail.com, robotframework-users
2011/8/31 Joaquim P <jp.cai...@gmail.com>:

>
> I'm using Force tags and setting a tag for all tests: coresmoke tag.
> Then, in Suite Setup, I'm removing that tag under certain
> circumstances using Remove Tags Keyword:
>
> Run Keyword Unless      '${ADAPT_DEPLOY_STATUS}' == '0'         Remove Tags
> coresmoke
>
> In Robot Test report, I can see for the test that the tag was removed:
> Tags:   ATDD, bring_up, Not_Critical, PSI-5, smoke, US_28014, US_28016,
> US_28017, US_28019
>
> But the test is executed anyway.

The reason this happens is that tests to run are selected before the
actual test execution starts. Changes to tags while tests are run thus
have no effect on that.

I can understand that allowing tag changes done in suite setup to
affect execution would be useful in some cases. Unfortunately
implementing that would be very hard at the moment, but we plan to
refactor the execution logic anyway at some point and after that this
could be doable. So feel free to submit an enhancement request to the
tracker!

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Joaquim P

unread,
Sep 3, 2011, 4:56:18 PM9/3/11
to robotframework-users
Hi,
I followed your suggestion and filled request 945:
http://code.google.com/p/robotframework/issues/detail?id=945

cheers,
Joaquim

On 2 Set, 11:47, Pekka Klärck <p...@iki.fi> wrote:
> 2011/8/31 Joaquim P <jp.caixapr...@gmail.com>:

Mikko Korpela

unread,
Sep 4, 2011, 1:50:47 AM9/4/11
to jp.cai...@gmail.com, robotframework-users
Hi,

One approach for fairly similar functionality is to fail the test at
the same time you change tags (add non-crititcal tag and fail).

I think this is the default way for handling situations were test
preconditions are not met.

Test is reported as non-critical failure -- but it will have (much)
less execution time.

Example:

pybot --noncritical  non-critical  .

*** Test Cases ***
Test some
 [Tags]    regression
 [Setup]  Check preconditions
 Sleep  10
 Log  long test

*** Keywords ***
Check preconditions
  ${not ok} =  Preconditions not OK
  Run Keyword If  ${not ok}  Non Critical Fail  'Preconditions not met'

Non Critical Fail
  [Arguments]  ${message}
  Add Tag  non-critical
  Fail  ${message}

Cheers,
Mikko

2011/9/3 Joaquim P <jp.cai...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "robotframework-users" group.
> To post to this group, send email to robotframe...@googlegroups.com.
> To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.
>
>

--
Mikko Korpela

Pekka Klärck

unread,
Sep 5, 2011, 8:43:08 AM9/5/11
to mikko....@gmail.com, jp.cai...@gmail.com, robotframework-users
2011/9/4 Mikko Korpela <mikko....@gmail.com>:

>
> One approach for fairly similar functionality is to fail the test at
> the same time you change tags (add non-crititcal tag and fail).
>
> I think this is the default way for handling situations were test
> preconditions are not met.
>
> Test is reported as non-critical failure -- but it will have (much)
> less execution time.

Very good point Mikko! Does this work for you Joaquim? You should at
least give it a try because it's unlikely that the support for
excluding tests dynamically is implemented in the near future.

Reply all
Reply to author
Forward
0 new messages