This is a migrated thread and some comments may be shown as answers.

end of test case event ?

7 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 29 Sep 2011, 10:16 AM
Hello,
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

Sort by
0
Stoich
Telerik team
answered on 29 Sep 2011, 12:10 PM
Hello Ali,
     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:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/add-custom-step/test-as-step.aspx

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.

Regards,
Stoich
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ali
Top achievements
Rank 1
answered on 29 Sep 2011, 12:19 PM
Hi,
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 ?
0
Stoich
Telerik team
answered on 30 Sep 2011, 12:39 PM
Hi Ali,
     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:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/knowledge-base/test-execution/execute-custom-scripts-before-after-test.aspx

I hope I've managed to clarify the issue for you, please let me know if you require any further info on this.

Kind regards,
Stoich
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John
Top achievements
Rank 2
answered on 30 Sep 2011, 01:43 PM
I see you might have two hurdals you might want to look at:

1: Data Drive your login

http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/data-driven-testing/local-data-driven-test.aspx

2: Coded steps

http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/coded_steps.aspx

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.

Thanks,
John Nicoulakos
0
Cody
Telerik team
answered on 30 Sep 2011, 11:05 PM
Hi John,

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.

public override void CleanUp()
{
    using (MyService service = new MyService())
    {
        service.MyMethod();
    }
    base.CleanUp();
}

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:

public void OnAfterTestCompleted(ExecutionContext executionContext, TestResult result)
{
    using (MyService service = new MyService())
    {
        service.MyMethod();
    }
}

Greetings,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 13 Jun 2018, 05:33 PM
JUnit is run often in tandem with Selenium WebDriver, to test a web app, and in that use case, is independent of the source code of the application under test.
0
Elena
Telerik team
answered on 18 Jun 2018, 02:09 PM
Hi Mark,

Thanks for the note! 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Ali
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Ali
Top achievements
Rank 1
John
Top achievements
Rank 2
Cody
Telerik team
Michael
Top achievements
Rank 1
Elena
Telerik team
Share this question
or