Maintaining context in a test

172 views
Skip to first unread message

Gaurav Arora

unread,
Jan 2, 2012, 12:45:06 PM1/2/12
to robotframe...@googlegroups.com

I have been trying to figure out if there is a built in way to maintain test context while a test is executing. The only way that i can see, after a read of the docs is to maintain context using a listener but they would require some boiler plate code. Let me explain why i need this.

We're trying to use robot framework for our integration testing. The tests must communicate with other components using a middleware layer. But i also need the tests to retain context so that complex communication is made possible using setup keywords. The context must be modifiable, ofcourse, for this to work. Additionally, this will also help in accessing results of a previous keyword internally without writing extra code in the higher level resource libraries.

Is this possible out of the box with robot framework?

Thanks,
Gaurav

Janne Härkönen

unread,
Jan 2, 2012, 11:46:30 PM1/2/12
to g.a...@iontrading.com, robotframe...@googlegroups.com
Hello Gaurav,

On Mon, Jan 2, 2012 at 7:45 PM, Gaurav Arora <g.a...@iontrading.com> wrote:
> We're trying to use robot framework for our integration testing. The tests
> must communicate with other components using a middleware layer. But i also
> need the tests to retain context so that complex communication is made
> possible using setup keywords. The context must be modifiable, ofcourse, for
> this to work. Additionally, this will also help in accessing results of a
> previous keyword internally without writing extra code in the higher level
> resource libraries.
>
> Is this possible out of the box with robot framework?

It seems to me that you need to create your own custom test library
with a global scope (so that it is instantiated only once during the
test run). The library can the keep track of the execution context,
and expose necessary keywords to test cases.

You can find more about test libraries in the user guide[1].

[1] http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.6.3#creating-test-libraries

thanks,
--J

--
Janne Härkönen | http://reaktor.fi
http://twitter.com/#!/janneharkonen

Gaurav Arora

unread,
Jan 3, 2012, 12:56:47 AM1/3/12
to Janne Härkönen, robotframe...@googlegroups.com
Hi Janne,

Thanks for the reply.

I'm not looking to maintain state across test cases. I only want to be able to maintain state across different keyword calls from a single test case so I can access that state later. Thanks for pointing out the scope, I missed that part of the docs, I think what I want to do may be possible with a "TEST CASE" scope where I will save state in the library class when keywords are called. I'm going to try this today.

Gaurav
Reply all
Reply to author
Forward
0 new messages