private TestReport DoTheRun(RunnerType runnerType, StatLightConfiguration statLightConfiguration) { using (IRunner runner = GetRunner( _logger, runnerType, statLightConfiguration, _statLightRunnerFactory)) { _logger.Debug("IRunner typeof({0})".FormatWith(runner.GetType().Name)); return(_runnerFunc(runner)); } }
public static Argument Create(IRunner runner, string argument) { _partialPath = new PartialPath(argument); var pshellType = runner.GetType(); Argument arg; if (pshellType.Equals(typeof(Powershell))) { arg = new PowershellArgument(runner); } else { arg = new CmdArgument(runner); } arg.PartialPath = _partialPath; arg.MatchStrategy = SetMatchStrategy(); return arg; }
public static void Run(this IRunner source, string line) { Type type = GetType(line.Split(" ")[0].ToLower()); string l = line.Substring(line.IndexOf(" ") + 1); string rgxStr = null; Object[] methodParams = null; MethodInfo method; // find method using found type and matching regex try { method = source.GetType().GetMethods().Where( m => m.GetCustomAttributes(type, false).Length > 0) .Where(s => s.GetCustomAttributesData() .Any(x => new Regex(x.ConstructorArguments.ToArray()[0].Value.ToString()).IsMatch(l))) .ToArray()[0]; } catch (Exception e) { Console.Error.WriteLine("\n{0}\n\t{1}", "FAILED TO FIND STEP", line); throw e; } // extract that regex so we can extract data rgxStr = method.GetCustomAttributesData().ToArray()[0].ConstructorArguments.ToArray()[0].Value.ToString(); // Extract data and save it to pass to the found method methodParams = GetMethodParameters(rgxStr, l); try { try { method.Invoke(source, methodParams); // run method } catch (TargetInvocationException tie) { throw tie.InnerException; } } catch (Exception e) { throw new AssertException(e.Message); } }
private TestReportCollection GetTestReports(RunnerType runnerType) { var testReports = new TestReportCollection(); IEnumerable <StatLightConfiguration> statLightConfigurations = _currentStatLightConfiguration.ToList(); if (runnerType == RunnerType.ContinuousTest) { IRunner continuousTestRunner = _statLightRunnerFactory.CreateContinuousTestRunner(statLightConfigurations); continuousTestRunner.Run(); } else { Stopwatch totalTime = Stopwatch.StartNew(); do { using (IRunner runner = GetRunner( _logger, runnerType, _currentStatLightConfiguration.Current, _statLightRunnerFactory)) { _logger.Debug("IRunner typeof({0})".FormatWith(runner.GetType().Name)); Stopwatch stopwatch = Stopwatch.StartNew(); TestReport testReport = runner.Run(); stopwatch.Stop(); testReports.Add(testReport); _eventPublisher.SendMessage(new TestReportGeneratedServerEvent(testReport, stopwatch.Elapsed, statLightConfigurations.Count() > 1)); } } while (_currentStatLightConfiguration.MoveNext()); totalTime.Stop(); _eventPublisher.SendMessage(new TestReportCollectionGeneratedServerEvent(testReports, totalTime.Elapsed)); } return(testReports); }
public void Setup() { TestContext.Write("Running using " + Runner.GetType().Name); }