示例#1
0
        public static async Task Run(RunDescriptor runDescriptor, List <EndpointBehavior> behaviorDescriptors, Func <ScenarioContext, bool> done)
        {
            Console.WriteLine("Started test @ {0}", DateTime.Now.ToString(CultureInfo.InvariantCulture));

            ContextAppenderFactory.SetContext(runDescriptor.ScenarioContext);
            var runResult = await PerformTestRun(behaviorDescriptors, runDescriptor, done).ConfigureAwait(false);

            ContextAppenderFactory.SetContext(null);

            Console.WriteLine("Finished test @ {0}", DateTime.Now.ToString(CultureInfo.InvariantCulture));

            var runSummary = new RunSummary
            {
                Result        = runResult,
                RunDescriptor = runDescriptor,
                Endpoints     = behaviorDescriptors
            };

            DisplayRunResult(runSummary);

            if (runSummary.Result.Failed)
            {
                throw runSummary.Result.Exception;
            }
        }
示例#2
0
        public static async Task Run(List <RunDescriptor> runDescriptors, List <EndpointBehavior> behaviorDescriptors, List <IScenarioVerification> shoulds, Func <ScenarioContext, bool> done, Action <RunSummary> reports)
        {
            var totalRuns = runDescriptors.Count;

            var results = new ConcurrentBag <RunSummary>();

            try
            {
                foreach (var runDescriptor in runDescriptors)
                {
                    Console.WriteLine("{0} - Started @ {1}", runDescriptor.Key, DateTime.Now.ToString(CultureInfo.InvariantCulture));

                    ContextAppenderFactory.SetContext(runDescriptor.ScenarioContext);
                    var runResult = await PerformTestRun(behaviorDescriptors, shoulds, runDescriptor, done).ConfigureAwait(false);

                    ContextAppenderFactory.SetContext(null);

                    Console.WriteLine("{0} - Finished @ {1}", runDescriptor.Key, DateTime.Now.ToString(CultureInfo.InvariantCulture));

                    results.Add(new RunSummary
                    {
                        Result        = runResult,
                        RunDescriptor = runDescriptor,
                        Endpoints     = behaviorDescriptors
                    });

                    if (runResult.Failed)
                    {
                        break;
                    }
                }
            }
            catch (OperationCanceledException)
            {
                Console.WriteLine("Test run aborted due to test failures");
            }

            var failedRuns = results.Where(s => s.Result.Failed).ToList();

            foreach (var runSummary in failedRuns)
            {
                DisplayRunResult(runSummary, totalRuns);
            }

            if (failedRuns.Any())
            {
                throw new AggregateException("Test run failed due to one or more exceptions", failedRuns.Select(f => f.Result.Exception)).Flatten();
            }

            foreach (var runSummary in results.Where(s => !s.Result.Failed))
            {
                DisplayRunResult(runSummary, totalRuns);

                reports?.Invoke(runSummary);
            }
        }
示例#3
0
        public static async Task <RunSummary> Run(RunDescriptor runDescriptor, List <IComponentBehavior> behaviorDescriptors, Func <ScenarioContext, bool> done)
        {
            Console.WriteLine("Started test @ {0}", DateTime.Now.ToString(CultureInfo.InvariantCulture));

            ContextAppenderFactory.SetContext(runDescriptor.ScenarioContext);
            var runResult = await PerformTestRun(behaviorDescriptors, runDescriptor, done).ConfigureAwait(false);

            ContextAppenderFactory.SetContext(null);

            Console.WriteLine("Finished test @ {0}", DateTime.Now.ToString(CultureInfo.InvariantCulture));

            return(new RunSummary
            {
                Result = runResult,
                RunDescriptor = runDescriptor,
                Endpoints = behaviorDescriptors
            });
        }