public static TestState GetTestStateFromReport(TestRunResults runDesc)
{
try
{
if (!Directory.Exists(runDesc.ReportLocation))
{
runDesc.ErrorDesc = string.Format(Resources.DirectoryNotExistError, runDesc.ReportLocation);
runDesc.TestState = TestState.Error;
return runDesc.TestState;
}
//if there is Result.xml -> UFT
//if there is sla.xml file -> LR
string[] resultFiles = Directory.GetFiles(runDesc.ReportLocation, "Results.xml",
SearchOption.TopDirectoryOnly);
if (resultFiles.Length == 0)
resultFiles = Directory.GetFiles(runDesc.ReportLocation, "run_results.xml",
SearchOption.TopDirectoryOnly);
//resultFiles = Directory.GetFiles(Path.Combine(runDesc.ReportLocation, "Report"), "Results.xml", SearchOption.TopDirectoryOnly);
if (resultFiles != null && resultFiles.Length > 0)
return GetTestStateFromUFTReport(runDesc, resultFiles);
resultFiles = Directory.GetFiles(runDesc.ReportLocation, "SLA.xml", SearchOption.AllDirectories);
if (resultFiles != null && resultFiles.Length > 0)
{
return GetTestStateFromLRReport(runDesc, resultFiles);
}
//no LR or UFT => error
runDesc.ErrorDesc = string.Format("no results file found for " + runDesc.TestName);
runDesc.TestState = TestState.Error;
return runDesc.TestState;
}
catch (Exception e)
{
return TestState.Unknown;
}
}