Sharing methods between tests

1.Is there anyway to share methods between tests ? something like using global methods. Lets say I have a login procedure I want to use in some of my tests , do I have to define it as a custom keyword or can I define a method and share it between tests?

2.Can I define a global “setup/teardown” method for the whole test suite? or is it only possible to define setup for each test individually ?

3.Can I define a set of custom keywords and repository objects and pack them as an external library to share between projects ?

Thank you!

I think you should

First start a Spy Web Session.
Navigate to the target screen in your application ( Ensure that no objects are added or selected until you reach your target screen).
From the target screen capture the target object
Click Add to Object Repository
Uncheck the Create New folder(s) as Page’s Name
Select and existing folder as destination folder and Click Ok.

The new object get added to the list of objects in the existing folder

Hi , another question I have is regarding the object repository - every time I record , the captured elements are added to another new folder under the object repository. The problem I have is that I already have those objects from previous tests I recorded , So now they are duplicated . I know I can choose not to save the new ones , but that will make me have to change the recorded script to use the old ones.Is there a way to avoid this case and make it compare the objects to the current repository and find duplicates? If not it will be a very important feature to have.


Thanks for all of your suggestions. We are currently implementing setup/teardown for test suite level and it will become available in future releases.

Regard to the current topic, you can also create a test case and call it using ‘Call Test Case’ keyword. It will also be shared between test cases as well.

Hi , it is possible to call from a keyword to another , I do it a lot - just import the class of the keyword you want to use to the new keyword class and call the old keyword function within the new one. Make sure it is a static function.

OK,Test suite common setup can be a nice feature in the future since this is the way people usually work in junit/nunit.

Thank you !

Hi there,

Custom keyword is shared between test cases. You can define your own custom keyword and use it between other test cases if you want to.
Test Suite current doesn’t support the ability to define ‘setup/teardown’ in that level. They are only available in test case level.
You can define a set of custom keywords and objects then share them to other projects by copying them to relative folders