private async Task DoRunTest(TestRun testRun) { this.logger.LogInformation($"Starting execution of test '{testRun.TestDefinition.Id}'."); try { var context = new TestContext(); foreach (var testCommand in testRun.TestDefinition) { ITestCommandResult commandResult = await this.RunCommand(testRun, testRun.TestDefinition, testCommand, context); testRun.AddCommandResult(commandResult); bool shouldTerminate = this.ProcessTestResult(testCommand, commandResult, testRun.Configuration); if (shouldTerminate) { this.logger.LogWarning("Prematurely terminating test."); break; } } } catch (Exception ex) { this.logger.LogError(ex, $"Unexpected error running test {testRun.Id}."); testRun.MarkAsFailed(ex.Message); } }