Sunday, March 27, 2016

Coded UI Test: How to continue execution after test case is failed.

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.

  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.

  1. Execute this ordered test. you will notice that test cases are not stop executing even if any test case is  failed.

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, correct strategy is to check if the test case status is 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.
  1. Open your testcase.cs file
  • Un-comment the testCleanup method.
  • Write below code in your test cleanup method.

[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. 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.
Cheers.

No comments:

Post a Comment