public string Run(Application app, ReflectionRunner runner, TestCase test) { var testResult = runner.RunTest(test, app).Result; string results; if (testResult.State == TestState.Failed) { results = $"====> Test FAILED #{testResult.TestClass}: {testResult.MethodName}:\n{testResult.Message} \n{testResult.StackTrace}\n\n"; } else { results = $"====> Test SUCCEEDED #{testResult.TestClass}: {testResult.MethodName}\n"; } return(results); }
public string Run(Application app, RunRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var stringBuilder = new StringBuilder(); ReflectionRunner runner = new ReflectionRunner(); foreach (TestCase test in request.Cases) { stringBuilder.Append(Run(app, runner, test)); } return(stringBuilder.ToString()); }
/// <summary> /// Run desired tests. /// </summary> private void Run(RunRequest request, Response response, UIApplication application) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (response == null) { throw new ArgumentNullException(nameof(response)); } string summaryPath = Path.Combine(response.Directory, FileNames.RunSummary); LogInfo(summaryPath, $"Test Request '{request.Id}' - {request.ClientName} ({request.ClientVersion})"); RunResult runResult = new RunResult { Id = request.Id, StartTime = DateTime.Now, State = TestState.Running, Cases = request.Cases.ToArray(), SummaryFile = summaryPath }; RevitTask runnerTask = new RevitTask(); ReflectionRunner runner = new ReflectionRunner(); runnerTask.Run(async uiApplication => { try { runResult.Cases = request.Cases; foreach (TestCase test in request.Cases) { var runTestResult = runResult.Cases.Single(t => t.Id == test.Id); WriteTestResultFile(response.Directory, runResult, false); var testResult = await runner.RunTest(test, application.Application); runTestResult.State = testResult.State; runTestResult.Message = testResult.Message; runTestResult.StackTrace = testResult.StackTrace; LogInfo(summaryPath, $"{test.Id,-8} Test {test.State,-7} - {test.TestClass}.{test.MethodName}"); if (!string.IsNullOrEmpty(test.Message)) { LogInfo(summaryPath, $"\t{test.Message}"); } if (!string.IsNullOrEmpty(test.StackTrace)) { LogInfo(summaryPath, $"\t{test.StackTrace}"); } } } catch (Exception e) { runResult.Output = e.ToString(); LogInfo(summaryPath, e); } WriteTestResultFile(response.Directory, runResult, true); LogInfo(summaryPath, $"Test run end - duration {runResult.Timestamp - runResult.StartTime}"); }); }