end of test case event ?

6 posts, 0 answers
  1. Ali
    Ali avatar
    3 posts
    Member since:
    Sep 2011

    Posted 29 Sep 2011 Link to this post

    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 ?
  2. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 29 Sep 2011 Link to this post

    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
  3. Ali
    Ali avatar
    3 posts
    Member since:
    Sep 2011

    Posted 29 Sep 2011 Link to this post

    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 ?
  4. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 30 Sep 2011 Link to this post

    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
  5. John
    John avatar
    8 posts
    Member since:
    Jul 2012

    Posted 30 Sep 2011 Link to this post

    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
  6. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 30 Sep 2011 Link to this post

    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
Back to Top