Test Teardown - run more than one keyword?

653 views
Skip to first unread message

Robert Spielmann

unread,
May 27, 2010, 4:09:58 PM5/27/10
to robotframework-users
Hi all,

in addition to "Teardown Selenium", I have some tests for which I need
to run at least one additional keyword on test teardown. Is there any
way to use Test Teardown with more than one keyword, or would I have
to wrap the keywords I want to run into one keyword like "Test-XY
Specific Teardown"?

Cheers
Robert

Cem Catikkas

unread,
May 27, 2010, 11:48:34 PM5/27/10
to spielman...@googlemail.com, robotframework-users
Yes you can create a new Keyword which in tern calls all the other
Keywords you want executed at Test Teardown.

Cem

> --
> 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.
>
>

Robert Spielmann

unread,
May 28, 2010, 4:33:28 AM5/28/10
to robotframework-users
On 28 Mai, 05:48, Cem Catikkas <cem.catik...@gmail.com> wrote:
> Yes you can create a new Keyword which in tern calls all the other
> Keywords you want executed at Test Teardown.
>
> Cem

Yeah, that's what I did. What I would have liked though:

Test Teardown Cleanup Database
... Teardown Selenium

or:

Test Teardown Cleanup Database
Test Teardown Teardown Selenium

Both result in "Cleanup Database expected 0 arguments, got 1."

I find it a little ugly to create an extra keyword as a teardown
keyword wrapper ;)

Regards
Robert

Shark

unread,
May 28, 2010, 1:22:57 PM5/28/10
to spielman...@googlemail.com, robotframework-users
I agree with Robert: having more than one step in setup/teardown has better visibility.

Robert

Bryan Oakley

unread,
May 28, 2010, 1:44:36 PM5/28/10
to robotframework-users
On Fri, May 28, 2010 at 12:22 PM, Shark <bug...@gmail.com> wrote:
> I agree with Robert: having more than one step in setup/teardown has better
> visibility.
>

What if there was a keyword that was "Run Keywords", and it takes a
variable number of arguments?

You could then do:

[Teardown] | Run Keywords | Do Something | Do Something Else | Do Even more

Of course, this means you can't pass arguments to those other keywords.

Though, it seems like the best solution is just to support multiple
instances of a setting, which get run in order:

[Teardown] | Do Something
[Teardown] | Do Something Else
[Teardown] | Do Even More

That would require a bit of a fundamental change to how RIDE is
implemented, but RIDE limitations probably shouldn't drive the design
of robot.

Pekka Klärck

unread,
May 28, 2010, 8:04:31 PM5/28/10
to spielman...@googlemail.com, robotframework-users
2010/5/28 Robert Spielmann <spielman...@googlemail.com>:

> On 28 Mai, 05:48, Cem Catikkas <cem.catik...@gmail.com> wrote:
>> Yes you can create a new Keyword which in tern calls all the other
>> Keywords you want executed at Test Teardown.
>>
>> Cem
>
> Yeah, that's what I did. What I would have liked though:
>
> Test Teardown  Cleanup Database
> ...  Teardown Selenium
>
> or:
>
> Test Teardown  Cleanup Database
> Test Teardown  Teardown Selenium
>
> Both result in "Cleanup Database expected 0 arguments, got 1."

You got this error because repeating the setting name on the next row
is an old syntax for continuing long rows in the setting table. What
you did is thus identical to this:

Test Teardown Cleanup Database
... Teardown Selenium

Note that continuing rows with three dots like in the example above is
the recommended way and that the old syntax will probably be
deprecated at some point.

> I find it a little ugly to create an extra keyword as a teardown
> keyword wrapper ;)

I agree that sometimes it's slightly annoying to create a new higher
level keyword when you just need to run two keywords in setup or
teardown. The good news is that if you need to add more keywords you
can add them to the same keyword. On the other hand I find it more
clear that setup and teardown are always just single keyword. That
also makes the framework, and RIDE, design considerably easier so at
least I'm not too interested to change this functionality.

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

Pekka Klärck

unread,
May 28, 2010, 8:12:24 PM5/28/10
to oak...@bardo.clearlight.com, robotframework-users
2010/5/28 Bryan Oakley <oak...@bardo.clearlight.com>:

> On Fri, May 28, 2010 at 12:22 PM, Shark <bug...@gmail.com> wrote:
>> I agree with Robert: having more than one step in setup/teardown has better
>> visibility.
>>
>
> What if there was a keyword that was "Run Keywords", and it takes a
> variable number of arguments?
>
> You could then do:
>
> [Teardown] | Run Keywords | Do Something | Do Something Else | Do Even more
>
> Of course, this means you can't pass arguments to those other keywords.

This keyword could be added easily. Not being able to use arguments
shouldn't be that big a problem because there is always a workaround
to create a new higher level keyword.

> Though, it seems like the best solution is just to support multiple
> instances of a setting, which get run in order:
>
> [Teardown] | Do Something
> [Teardown] | Do Something Else
> [Teardown] | Do Even More
>
> That would require a bit of a fundamental change to how RIDE is
> implemented, but RIDE limitations probably shouldn't drive the design
> of robot.

Together the changes to the internal models, running, logging, and
RIDE's UI would be quite big, and as a bonus documentation should be
updated too. Personally I don't think that's worth the effort, but if
someone else is interested in it I'm willing to review patches. Adding
the proposed `Run Keywords` keyword would be much easier.

Pekka Klärck

unread,
Jun 7, 2010, 11:57:11 AM6/7/10
to oak...@bardo.clearlight.com, robotframework-users
2010/5/29 Pekka Klärck <pe...@iki.fi>:
> 2010/5/28 Bryan Oakley <oak...@bardo.clearlight.com>:

>>
>> What if there was a keyword that was "Run Keywords", and it takes a
>> variable number of arguments?
>>
>> You could then do:
>>
>> [Teardown] | Run Keywords | Do Something | Do Something Else | Do Even more
>>
>> Of course, this means you can't pass arguments to those other keywords.
>
> This keyword could be added easily. Not being able to use arguments
> shouldn't be that big a problem because there is always a workaround
> to create a new higher level keyword.

I considered adding this so good idea that I just implemented it:
http://code.google.com/p/robotframework/issues/detail?id=572
http://robotframework.googlecode.com/svn/trunk/doc/libraries/BuiltIn.html#Run%20Keywords

Robert Spielmann

unread,
Jun 8, 2010, 10:36:09 AM6/8/10
to robotframework-users
On 7 Jun., 17:57, Pekka Klärck <p...@iki.fi> wrote:

> I considered adding this so good idea that I just implemented it
>
> Cheers,
>     .peke

cool :)

Cheers
Robert
Reply all
Reply to author
Forward
0 new messages