You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Libraries should get notification when suites/tests/keywords start/end and when library is out of scope #811
Basically this would allow libraries to act as listeners. The most important use case is libraries with global or suite level scope to be able to handle test specific state easily, but I'm sure there are other usages too. Even more use case are possible if listeners are allowed to alter suite/test/keyword state (issue 177).
To make it easier to distinguish listener methods from keywords be probably should not use normal listener method names like start_test but add a prefix like listen_to_start_test. Regardless the name, this change is potentially backwards-incompatible because old keywords with these names won't work anymore. One possibility to prevent that is requiring libraries that act as listeners to have ROBOT_LISTENER_VERSION attribute.
An additional problem is handling dynamic libraries. One possibility is expecting also these libs to have listener methods directly in the class, but this approach does not support proxys such as Remote. Allowing listener names to be returned from get_keyword_names and executed via run_keyword would be better but harder to implement. Notice also that requiring special attributes is something that does not work with proxy libraries either.
Another idea:
Libraries and resource files could have setup and teardown functions / keywords.
This would allow cross suite setup and teardown reuse. For example a resource file could be used to completely setup and teardown the system under test or a connection or open/close some file etc..
As this is needed inside NSN, we are adding this to 2.8.5.
We ended up deciding that this would work by library having an attribute ROBOT_LIBRARY_LISTENER which has the listener instance as value. This can be self. To avoid having the listener methods visible as keywords, the method names can also start with underscore.
Changing the test status etc will not be supported for now and neither are Remote libraries.
This way the changes should be also backwards compatible.
If a library works as a listener, it is created at the beginning of the scope. (Test scope listener will get start test event, suite scope will get the start suite etc)
Documented the new functionality in User Guide. Jussi, and everyone
else interested, please review and let me know if something is missing
or is not clear.
@bryan.oakley Yeah, this functionality provides lot of interesting capabilities. I'm pretty happy about the design too. It's really easy to make a library act as a lis
r2c8f8b6cea69 contains a fix to allow module libraries to have a listener.
I didnt make a separate test for all features though. The module test has a listener with api version v1, and the listener is external (not the module itself, which you could access with a hackish way of sys.modules[name])
The empty library also got now log_message implemented to verify that also.
r62c8ed20ad22 has test to verify that libraries taken into use with import library also work.
Activity
spooning commentedon Jun 29, 2014
Another idea:
Libraries and resource files could have setup and teardown functions / keywords.
This would allow cross suite setup and teardown reuse. For example a resource file could be used to completely setup and teardown the system under test or a connection or open/close some file etc..
spooning commentedon Jun 29, 2014
Initially descoped from 2.6 and moved to 2.7.
spooning commentedon Jun 29, 2014
Issue 857 has been merged into this issue.
spooning commentedon Jun 29, 2014
Initially descoped from 2.7 due to lack of time
spooning commentedon Jun 29, 2014
As this is needed inside NSN, we are adding this to 2.8.5.
We ended up deciding that this would work by library having an attribute ROBOT_LIBRARY_LISTENER which has the listener instance as value. This can be self. To avoid having the listener methods visible as keywords, the method names can also start with underscore.
Changing the test status etc will not be supported for now and neither are Remote libraries.
This way the changes should be also backwards compatible.
spooning commentedon Jun 29, 2014
This issue was updated by revision a67147545207.
First implementation still lacking tests and support for methods starting with underscore.
spooning commentedon Jun 29, 2014
This issue was updated by revision ba322e157438.
Added missing librarylisteners.py and also some tests
spooning commentedon Jun 29, 2014
This issue was updated by revision f1c15e0bfa69.
Added support for methods names starting with underscore
spooning commentedon Jun 29, 2014
This issue was updated by revision dcbc2df1b16c.
If a library works as a listener, it is created at the beginning of the scope. (Test scope listener will get start test event, suite scope will get the start suite etc)
spooning commentedon Jun 29, 2014
This issue was updated by revision f2fcbe6f0011.
Now works with java
spooning commentedon Jun 29, 2014
This issue was updated by revision e91d3dfdd21a.
support starting with underscore in Java
spooning commentedon Jun 29, 2014
This issue was updated by revision b4e92a185fb7.
Add tests for suite setup and teardown events in test scope
spooning commentedon Jun 29, 2014
This issue was updated by revision 51f5609306a5.
Cleanup and more tests
spooning commentedon Jun 29, 2014
This issue was updated by revision d0aa87b9c5af.
Cleanup
spooning commentedon Jun 29, 2014
This looks very useful. It makes it trivial to implement the "Require test case" keyword that I requested in issue #1710 .
spooning commentedon Jun 29, 2014
This issue was updated by revision 970e12328222.
Now calling close method from library listener when ending the scope for that library.
spooning commentedon Jun 29, 2014
This issue was updated by revision 444ad697ff45.
Documented the new functionality in User Guide. Jussi, and everyone
else interested, please review and let me know if something is missing
or is not clear.
spooning commentedon Jun 29, 2014
@bryan.oakley Yeah, this functionality provides lot of interesting capabilities. I'm pretty happy about the design too. It's really easy to make a library act as a lis
spooning commentedon Jun 29, 2014
r2c8f8b6cea69 contains a fix to allow module libraries to have a listener.
I didnt make a separate test for all features though. The module test has a listener with api version v1, and the listener is external (not the module itself, which you could access with a hackish way of sys.modules[name])
The empty library also got now log_message implemented to verify that also.
r62c8ed20ad22 has test to verify that libraries taken into use with import library also work.
I think this feature should be done.
spooning commentedon Jun 29, 2014
User Guide reviewed, looks okay
spooning commentedon Jun 29, 2014
Latest code changes look good too. Closing and looking forward to see this functionality to be used in real life!