Hello Kevin,
We have had very similar problems with the fact that the keywords imported into the __init__ file are not available in the test case files. This is documented functionality, if you look at the Robot user guide (section about initialisation files).
In order to get your tests to pass, you need to import your library into both test1.txt and test2.txt as the teardown is effectively run as if it was defined locally in test1.txt and test2.txt.
I am not sure why there is this restriction on not using the __init__ file to perform library imports on behalf of the entire test suite, but maybe one of the developers will be able to shed some light on that.
Regards,
Florian
On Monday, 22 October 2012 14:59:43 UTC+1, Kevin wrote:
Hello,
I am having a hard time figuring out why the __init__.txt does not work as I expect.
Lets say you have the following test suite:
mytestsuite
__init__.txt
Both test1.txt and test2.txt contain the following testcase that does nothing more than:
*** Testcases ***
Test Foo
Open Browser http://www.google.nl
And __init__.txt does not contain anything else other than:
*** Settings ***
Library SeleniumLibrary
Test Teardown Close Browser
Now if I do:
pybot mytestsuite
Then the test teardown is applied to all testcases in the suite. In this case, both tests will pass.
init.jpg has a screenshot of all previous actions.
With this principle, we started making our own library, this library contains a keyword that needs to be executed as a test teardown for every test.
The context.py library contains the following code:
context = {}
def clear_context():
context.clear()
Upon importing this library, this should give access to the Clear Context keyword.
*** Settings ***
Library ../lib/context.py
*** Testcases ***
Test Foo
Clear Context
This is proven by the lib.jpg screenshot. (I temporary changed test1.txt for sake of example)
Now can anyone explain to me why importing this library in the __init__.txt file, and using Clear Context as test Teardown does not work? See lib_init.jpg
Thanks for any assistance!
BR,
Kevin