/// <summary>
/// creates a correct type of runner and runs a single test.
/// </summary>
/// <param name="testPath"></param>
/// <param name="errorReason"></param>
/// <returns></returns>
private TestRunResults RunHPToolsTest(TestInfo testinf, ref string errorReason)
{
var testPath = testinf.TestPath;
var type = Helper.GetTestType(testPath);
IFileSysTestRunner runner = null;
switch (type)
{
case TestType.ST:
runner = new ApiTestRunner(this, _timeout - _stopwatch.Elapsed);
break;
case TestType.QTP:
runner = new GuiTestRunner(this, _useUFTLicense, _timeout - _stopwatch.Elapsed, _mcConnection, _mobileInfoForAllGuiTests);
break;
case TestType.LoadRunner:
AppDomain.CurrentDomain.AssemblyResolve += Helper.HPToolsAssemblyResolver;
runner = new PerformanceTestRunner(this, _timeout, _pollingInterval, _perScenarioTimeOutMinutes, _ignoreErrorStrings);
break;
}
if (runner != null)
{
if (!_colRunnersForCleanup.ContainsKey(type))
{
_colRunnersForCleanup.Add(type, runner);
}
Stopwatch s = Stopwatch.StartNew();
TestRunResults results = null;
results = runner.RunTest(testinf, ref errorReason, RunCancelled);
results.Runtime = s.Elapsed;
if (type == TestType.LoadRunner)
{
AppDomain.CurrentDomain.AssemblyResolve -= Helper.HPToolsAssemblyResolver;
}
return(results);
}
//check for abortion
if (System.IO.File.Exists(_abortFilename))
{
ConsoleWriter.WriteLine(Resources.GeneralStopAborted);
//stop working
Environment.Exit((int)Launcher.ExitCodeEnum.Aborted);
}
return(new TestRunResults {
ErrorDesc = "Unknown TestType", TestState = TestState.Error
});
}