Ejemplo n.º 1
0
        private ITestReport CreateReport([NotNull] ITest test, [NotNull] ITestProcessingContext context)
        {
            Assert.ArgumentNotNull(test, nameof(test));
            Assert.ArgumentNotNull(context, nameof(context));

            return(new TestReport(test, context.Results));
        }
Ejemplo n.º 2
0
        public ITestReport RunTest(ITest test, TResource data, ITestProcessingContext context)
        {
            Assert.ArgumentNotNull(test, nameof(test));
            Assert.ArgumentNotNull(data, nameof(data));
            Assert.ArgumentNotNull(context, nameof(context));

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            try
            {
                var report = DoRunTest(test, data, context);
                stopwatch.Stop();
                report.ExecutionTime = stopwatch.Elapsed;

                return(report);
            }
            finally
            {
                stopwatch.Stop();
            }
        }
 protected override void ProcessTest(ITest test, ISolutionResourceContext data, ITestProcessingContext context)
 {
     test.Process(data, context);
 }
Ejemplo n.º 4
0
        private ITestReport DoRunTest([NotNull] ITest test, [NotNull] TResource data, [NotNull] ITestProcessingContext context)
        {
            Assert.ArgumentNotNull(test, nameof(test));
            Assert.ArgumentNotNull(data, nameof(data));
            Assert.ArgumentNotNull(context, nameof(context));

            try
            {
                if (!IsTestActual(test, data))
                {
                    if (!context.Results.All.Any())
                    {
                        context.Results.Add(new TestOutput(TestResultState.CannotRun, "Test is not actual for given conditions"));
                    }

                    return(CreateReport(test, context));
                }
            }
            catch (ResourceNotAvailableException ex)
            {
                if (!context.Results.All.Any())
                {
                    context.Results.Add(new TestOutput(TestResultState.CannotRun, $"Test failed to run due to missing resource: {ex.Message}", null, new DetailedMessage(new CodeBlock(ex.PrintException()))));
                }

                return(CreateReport(test, context));
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Test failed with unhandled exception");

                context.Results.Add(new TestOutput(TestResultState.CannotRun, "Checking test preconditions failed with unhandled exception. " + ex.Message.TrimEnd('.') + ". Find details in the log file.", null, new DetailedMessage(new CodeBlock(ex.PrintException()))));
            }

            return(RunTestInner(test, data, context));
        }
Ejemplo n.º 5
0
 protected abstract void ProcessTest(ITest test, TResource data, ITestProcessingContext context);