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
- Open ordered test case by double clicking on it.
- There is a check box “Continue after failure” on the bottom left. Make sure it is checked.
- 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:
[TestCleanup()]
public void MyTestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
{
}
}
- Open your testcase.cs file
- Un-comment the
testCleanup
method - Write the below code in your test cleanup method
- 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.