Click here to Skip to main content
15,910,981 members
Articles / Programming Languages / C#

Coded UI Test: How to Continue Execution After Test Case Fails

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
13 Aug 2013CPOL1 min read 17.1K   1   2
How to continue execution after test case fails

Introduction

When we are executing a batch of test cases using ordered test, in some situations, we want to continue the execution even if one of the test cases failed. After execution, we want to see the complete report stating passed and failed test cases. This strategy is good for testers who want to execute test cases when they are not on seat.

1. For Easy Scenarios

orderedtestcaseEditor

  1. Open ordered test case by double clicking on it.
  2. There is a check box “Continue after failure” on the bottom left. Make sure it is checked.
  3. Execute this ordered test. you will notice that test cases do not stop executing even if any test case fails.

2. For Difficult Scenarios

Sometimes, test cases fail due to an expected message box. In that kind of scenarios, subsequent test cases will begin to fail one by one.

For that kind of scenario, the correct strategy is to check if the test case status failed, if yes then move the application under test to a base state and subsequent test cases should start from that base state.

We can achieve this in coded UI test by the use of coded UI test. Following are the steps:

C#
[TestCleanup()]
public void MyTestCleanup()
{
    if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
    //check if the test case is failed
    {
        // write some code here to move your application
        // to a base state , for e.g. restart your application
        // Process.Kill("yourapplication.exe");
        // Playback.Wait(3000);
        //Process.Start("yourapplication.exe");
    }
}
  1. Open your testcase.cs file
  2. Un-comment the testCleanup method
  3. Write the below code in your test cleanup method
  4. Note that testcleanup method executes after each test case

I hope the above scenarios will help test engineers to execute test cases in a much better way.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Tester / Quality Assurance
Pakistan Pakistan
Working as a Testing Automation Engineer.

Comments and Discussions

 
QuestionAbout Coded UI Pin
Member 1341556918-Sep-17 1:35
Member 1341556918-Sep-17 1:35 
QuestionHand coded CUIT (Coded UI Test) Pin
Burdette Lamar12-Apr-14 4:49
Burdette Lamar12-Apr-14 4:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.