Example #1
0
        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);
            }
        }
Example #2
0
        private bool ProcessTestResult(ITestCommand command, ITestCommandResult commandResult, TestRunConfiguration configuration)
        {
            if (!commandResult.ExecutedSuccessfully)
            {
                this.logger.LogWarning($"Executed command {command.Id} with failure result.");

                if (configuration.ExitOnFailure)
                {
                    this.logger.LogWarning($"Test is configured with ExitOnFailure; quitting test.");
                    return(true);
                }
            }
            else
            {
                this.logger.LogInformation($"Executed command {command.Id} with success result.");
            }

            return(false);
        }
Example #3
0
 public void AddCommandResult(ITestCommandResult commandResult)
 {
     this.commandResults.Add(commandResult);
 }