In this following example I wanted to capture a screen shot only if the result had failed.
[TestCleanup]
public void CleanUpTest()
{
if(TestContext.CurrentTestOutcome!=UnitTestOutcome.Passed)
{
Tool.GetScreenShot();
Tool.SaveScreenShot();
}
}
The TestContext.CurrentTestOutcome property will reference a UnitTestOutcome enumerator. In the above example, if the test hadn't passed, then on clean up I will take a screen shot, and then save all screen shots to a result file. .
No comments:
Post a Comment