Пример #1
0
        /// <summary>
        /// Runs all assembles.
        /// </summary>
        /// <param name="resultFormatter">The result formatter.</param>
        /// <returns></returns>
        public async Task <NSpecResultSummaryModel> RunAllAssembles(IFormatterWithOutput resultFormatter)
        {
            var task = Task.Run <NSpecResultSummaryModel>(() =>
            {
                StringBuilder builder = new StringBuilder();
                var assemblies        = _loadedAssemblies.Keys;
                var summary           = new NSpecResultSummaryModel();

                var stopWatch = new System.Diagnostics.Stopwatch();
                stopWatch.Start();

                foreach (var assembly in assemblies)
                {
                    var result             = RunTests(assembly, string.Empty, resultFormatter).Result;
                    summary.TotalExecuted += result.ContextCollection.Examples().Count();
                    summary.TotalFailed   += result.ContextCollection.Failures().Count();
                    summary.TotalErrors    = summary.TotalFailed;
                    builder.AppendLine(result.Output);
                }
                stopWatch.Stop();
                summary.TimeTake = stopWatch.Elapsed.Seconds;
                summary.Output   = builder.ToString();
                return(summary);
            });

            return(await task);
        }
 public ContextRunnerInvocator(string dll, string tags, IFormatterWithOutput formatter, bool failFast)
 {
     this._dllFile   = dll;
     this._failFast  = failFast;
     _tags           = tags.Trim().Replace(" ", "_");
     _formatter      = formatter;
     _tagsCollection = new List <string>();
 }
 public ContextRunnerInvocator(string dll, string tags, IFormatterWithOutput formatter, bool failFast)
 {
     this._dllFile = dll;
     this._failFast = failFast;
     _tags = tags.Trim().Replace(" ","_");
     _formatter = formatter;
     _tagsCollection = new List<string>();
 }
Пример #4
0
        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="uniqueSpecName">Name of the unique spec.</param>
        /// <param name="resultFormatter">The result formatter.</param>
        /// <returns></returns>
        public async Task<NSpecResultModel> RunTests(string assembly, string uniqueSpecName, IFormatterWithOutput resultFormatter)
        {
            var task = Task.Run(() =>
            {
                var tags = GetTags(assembly, uniqueSpecName);
                var runnerInvocation = new ContextRunnerInvocator(assembly, tags, resultFormatter, false);
                _activeDomain = new NSpecTestDomain(assembly);
                return _activeDomain.Run(runnerInvocation, t => t.Run());
            });

            return await task;
        }
Пример #5
0
        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="uniqueSpecName">Name of the unique spec.</param>
        /// <param name="resultFormatter">The result formatter.</param>
        /// <returns></returns>
        public async Task <NSpecResultModel> RunTests(string assembly, string uniqueSpecName, IFormatterWithOutput resultFormatter)
        {
            var task = Task.Run(() =>
            {
                var tags             = GetTags(assembly, uniqueSpecName);
                var runnerInvocation = new ContextRunnerInvocator(assembly, tags, resultFormatter, false);
                _activeDomain        = new NSpecTestDomain(assembly);
                return(_activeDomain.Run(runnerInvocation, t => t.Run()));
            });

            return(await task);
        }
Пример #6
0
        /// <summary>
        /// Runs all assembles.
        /// </summary>
        /// <param name="resultFormatter">The result formatter.</param>
        /// <returns></returns>
        public async Task<NSpecResultSummaryModel> RunAllAssembles(IFormatterWithOutput resultFormatter)
        {
            var task = Task.Run<NSpecResultSummaryModel>(() =>
            {
                StringBuilder builder = new StringBuilder();
                var assemblies = _loadedAssemblies.Keys;
                var summary = new NSpecResultSummaryModel();

                var stopWatch = new System.Diagnostics.Stopwatch();
                stopWatch.Start();

                foreach (var assembly in assemblies)
                {
                    var result = RunTests(assembly, string.Empty, resultFormatter).Result;
                    summary.TotalExecuted += result.ContextCollection.Examples().Count();
                    summary.TotalFailed += result.ContextCollection.Failures().Count();
                    summary.TotalErrors = summary.TotalFailed;
                    builder.AppendLine(result.Output);
                }
                stopWatch.Stop();
                summary.TimeTake = stopWatch.Elapsed.Seconds;
                summary.Output = builder.ToString();
                return summary;
            });
            return await task;
        }