I have an iteration of tests I am running that is data driven. We are using the following code to test if the testcase has failed, however once a single iteration fails every iteration thereafter returns a failed value, even though the iteration's tests were successful. I believe this is because TestReport.CurrentTestCaseActivity returns the failure/success of the current test case rather than the current test case's iteration. Is there a way to get the iteration's failure/success value?
Here is the code we are using:
Code: Select all
static class FailedFinder
{
static public Activity Failed = null;
static public void Search(Activity act)
{
foreach (Activity child in act.Children)
{
if (child is TestModuleActivity)
{
if (child.Status == Ranorex.Core.Reporting.ActivityStatus.Failed)
Failed = child;
}
else
Search(child);
}
}
}
//this is a user code method
public void TestFail()
{
Report.Info("Checking if there was an error thrown.");
FailedFinder.Failed = null;
FailedFinder.Search(TestReport.CurrentTestCaseActivity);
if (FailedFinder.Failed != null)
{
//This is reached on every iteration after an iteration fails including the failed iteration.
// We want just the failed iteration to reach this section.
Report.Info("Error found.");
ErrorHandling();
}
}
public void ErrorHandling()
{
//do something here if iteration fails.
}