I am just trying out testStudio and created a simple record and playback in which I created a new user account using some our internal website. This test would fail next time because we would throw a 'duplicate account' error. Is there a way to have some kind of teardown/cleanup after a each test case ends in these simple record and playback tests ? What about other more advanced tests ?
7 Answers, 1 is accepted
you will have to record the necessary actions in order to remove the newly-created account. You can put the actions in a test as step and invoke them at the end of each test where they are needed as seen here:
Alternatively you can use create your own custom logic that generates randomized names for the accounts you create. In that way the newly-create accounts will not be duplicates. There are many possible ways to implement this workaround. I can provide some examples if you like.
the Telerik team
The only interface to 'cleanup' the data after test case execution is a web service that needs to be called. Most testing framework (junit, testng, etc) provide a teardown functionality for test cases. Does telerik provide some of kind of event handling mechanism where this 'cleanup code' can be invoked at the end of each test case ?
there are substantial differences between the Telerik Testing Framework and testing frameworks like Junit.
Telerik's Testing Framework is designed with UI Automation in mind. The teardown functionality you're referring to is not really applicable as a concept to Telerik's Testing Framework. This is because TTF does not have access to an application's backed implementation. It interacts only with the DOM Structure of a page inside the browser (in the same way a physicals user would). There's simply nothing to tear down - no "deeper integration" with the app occurs.
As far as I know Junit test have direct access to the code of an application's back end and perform their testing directly in there. This is a different concept from UI Automation.
Also I believe Junit can only perform testing on Java apps while TTF can test an web-based applications regardless of their back-end implementation. TTF only cares about the GUI of the app.
You should be able to invoke the required Web Service from code. You can put it in the OnAfterTestCompleted() method in your test as seen here:
I hope I've managed to clarify the issue for you, please let me know if you require any further info on this.
the Telerik team
1: Data Drive your login
2: Coded steps
The first one I have my user name and password in a list of data. My scripts index through the list and login in on the currest row of the table. The coded steps can have the code for your tear down. You can use VB.NET or C#.NET. I hope this helps.
Do you want this cleanup performed for all tests or a small select set of tests? For a specific test you can override the cleanup method in the code behind .cs file. It won't appear as a coded step, but must be placed in the class definition for the code behind of the test. Call your webservice via code then call the base class CleanUp method to insure the test is fully cleaned up.
If you want to do the same thing for all tests unconditionally, a similar hook exists in our test extension. A test extension will get loaded and executed for all tests you run on that machine unconditionally. Use the OnAfterTestCompleted method:
the Telerik team