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.
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.
[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");
}
}
Cheers.
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 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.
- 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");
}
}
- Note that testcleanup method executes after each test case.
Cheers.
No comments:
Post a Comment