Suite Multi-Keyword Setup/Teardown

7,915 views
Skip to first unread message

Josh

unread,
Apr 27, 2012, 2:36:24 PM4/27/12
to robotframe...@googlegroups.com
Hi,

I am encounter problems with Suite Setup / Suite Teardown..

--

What I want to do..
1) Import a remote library on suite setup that will then be available to all testcases

However, I am running into problems because it appears that Suite Startup / Teardown does not support the use of multiple-keywords and is only setup to run a single keyword (a bit ridiculous IMO).

To rectify this problem I have attempted.. to move Suite Setup / Teardown into a user defined keyword to be able to execute more than one keyword. I am now encounter problems because I do not think the Library import in the user-defined keyword is making it back to the main scope, same thing with the ${TestPlatformTar}

Also it appears that the following statement is not legal:
Suite Setup ${TestPlatformTar}= Suite Setup

So I have no idea how Suite Setup would actually be used to setup a variable.


The test:
---------

*** Variables ***
${TeacherHostAddr} "10.1.138.96"
${TeacherAddr} "10.1.123.1"
${TestPlatformPath} "c:/Dropbox/AppFW"


*** Settings ***
Library keywords/common/STAX.py
Suite Setup Suite Setup
Suite Teardown Suite Teardown

**** Test Cases ***
Start Assessment
TeacherHost.Revert Snapshot XP32 teacher
TeacherHost.Start XP32
STAX.Prepare Host ${TeacherAddr} keywords/notebook/Demo.py ${TestPlatformTar}
Import Library Remote http://${TeacherAddr}:8270 WITH NAME Teacher
Teacher.Find App
Teacher.Select Tab
Teacher.Start Assessment
*** Keyword ***
Suite Setup
${TestPlatformTar} = STAX.Create Tarball ${TestPlatformPath}
STAX.Prepare Host ${TeacherHostAddr} keywords/common/VMHost.py
Import Library Remote http://${TeacherHostAddr}:8270 WITH NAME TeacherHost
[Return] ${TestPlatformTar}


Suite Teardown
TeacherHost.Shutdown

------

Anyone have any ideas on work-arounds?

I would like to put in my informal feature request for multi-keyword Suite Setup / Teardown.

Thanks,

Josh


Taylor, Martin

unread,
Apr 27, 2012, 2:48:36 PM4/27/12
to smy...@gmail.com, robotframe...@googlegroups.com

Hi Josh,

 

A quick look at your test file below shows that you’re doing:

    [Return]           ${TestPlatformTar}

Which returns a variable to NOTHING.  If you want the value of ${TestPlatformTar} to be available outside the Suite Setup KW, then I would suggest replacing the above line with:

    Set Suite Variable    ${TestPlatformTar}

Which alters the scope of the ${TestPlatformTar} variable to Suite instead of local to the KW.

 

I’m not sure about the “Import Library” part… I’ve had trouble myself getting dynamic library imports like this to work.  Maybe others can advise in this area.

 

Cheers,

Martin

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

Josh

unread,
Apr 27, 2012, 3:42:03 PM4/27/12
to robotframe...@googlegroups.com
Hi Martin,

I wasn't aware of "Set Suite Variable" keyword, thank you.

In regards to the function returning a value to nothing, I was actually trying to use the return value in the following way: 

Suite Setup ${TestPlatformTar}= Suite Setup

But it appears that this statement is not legal as mentioned in original post.  But the keyword that you mentioned will remove the need for this all together... But you're right still leaves the library import issue there.

I might just have to include the import in every keyword, or keyword setup.

Josh

unread,
Apr 27, 2012, 3:44:50 PM4/27/12
to Taylor, Martin, robotframe...@googlegroups.com
Alright, crisis averted! 

It appears that the Suite Startup user-keyword is importing my library into the suite context.

Also the "Set Suite Variable" fixed my other problem.



On Fri, Apr 27, 2012 at 12:55 PM, Josh <smy...@gmail.com> wrote:
Hi Martin,

I wasn't aware of "Set Suite Variable" keyword, thank you.

In regards to the function returning a value to nothing, I was actually trying to use the return value in the following way: 
Suite Setup ${TestPlatformTar}= Suite Setup

But it appears that this statement is not legal as mentioned in original post.  But the keyword that you mentioned will remove the need for this all together... But you're right still leaves the library import issue there.

I might just have to include the import in every keyword, or keyword setup.
On Fri, Apr 27, 2012 at 12:48 PM, Taylor, Martin <cmta...@ti.com> wrote:

Pekka Klärck

unread,
Apr 28, 2012, 4:42:06 AM4/28/12
to smy...@gmail.com, robotframe...@googlegroups.com
2012/4/27 Josh <smy...@gmail.com>:
>
> However, I am running into problems because it appears that Suite Startup /
> Teardown does not support the use of multiple-keywords and is only setup to
> run a single keyword (a bit ridiculous IMO).

This has been discussed here few times earlier. Support for multiple
keywords as setup/teardown would require so big changes to the test
data syntax and internal changes to the framework (and RIDE) that it
is not considered feasible. It is also easy to create your own user
keywords, just like you did, and sometimes you can use BuiltIn `Run
Keywords` keyword:

| Run Keywords | Keyword 1 | Keyword 2 | Keyword 3 |

`Run Keywords` was actually proposed by someone (was it Bryan?) when
this issue was discussed here last time. A limitation of it is that
you cannot run keywords with arguments with it. That support could
possibly be added, for example, by allowing this:

| Run Keywords | Keyword 1 (arg) | Keyword 2 (arg1, arg2) |

The above might work pretty nicely with two or three keywords, but
with more keywords with lot of arguments the end result would be a
mess. A more concrete limitation would be that assigning variables
from keyword return variables would not work.

> Also it appears that the following statement is not legal:
> Suite Setup ${TestPlatformTar}= Suite Setup
>
> So I have no idea how Suite Setup would actually be used to setup a
> variable.

You are right, setting suite level variables like that is not
possible. As Martin already commented, you can accomplish that using
`Set Suite Variable` keyword. Setting the variable from the return
value of the setup keyword could sometimes be handy, but I'm not sure
is it worth the implementation effort.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages