示例#1
0
        public void GenerateReport(ISuiteResult results)
        {
            var data     = new Dictionary <string, object>();
            var compiler = new FormatCompiler();

            var assembly  = Assembly.GetExecutingAssembly();
            var stream    = assembly.GetManifestResourceStream("WebDriverRunner.reporters.Trx.template.xml");
            var reader    = new StreamReader(stream);
            var generator = compiler.Compile(reader.ReadToEnd());

            data["Name"] = results.Name;

            data["allCount"]     = results.Results().Count;
            data["passedCount"]  = results.PassedTests.Count;
            data["failedCount"]  = results.FailedTests.Count;
            data["skippedCount"] = results.SkippedTests.Count;

            data["all"] = results.Results();


            var duration = string.Format(" total :{0:%m}min{0:%s}sec ", results.Total);

            data["summary"] = "(" + results.PassedTests.Count + "," +
                              +results.FailedTests.Count + "," +
                              +results.SkippedTests.Count + ")" + duration;

            var content = generator.Render(data);

            var file = new StreamWriter(Output + "/" + "template.trx");

            file.Write(content);
            file.Close();
        }
示例#2
0
        public void GenerateReport(ISuiteResult results)
        {
            var totalConfigFailed  = results.FailedConfiguration.Count;
            var totalConfigSkipped = results.SkippedConfiguration.Count;

            var totalTestPassed  = results.PassedTests.Count;
            var totalTestFailed  = results.FailedTests.Count;
            var totalTestSkipped = results.SkippedTests.Count;

            var total = results.Total;

            var summary = "-------------" + results.GetStatus() + "---------\n";

            summary += "Ran " + (totalTestPassed + totalTestFailed + totalTestSkipped) + " tests (" + DurationPretty(total) + ")\n";
            if ((totalTestFailed + totalTestSkipped) != 0)
            {
                summary += "\nTest Methods(" + results.GetTotalTests() + "):\n";
                summary += "\tFailed: " + totalTestFailed + "\n";
                summary += "\tSkipped: " + totalTestSkipped + "\n";
            }

            if ((totalConfigFailed + totalConfigSkipped) != 0)
            {
                summary += "\nConfiguration Methods(" + results.GetTotalConfiguration() + "):\n";
                summary += "\tFailed:" + totalConfigFailed + "\n";
                summary += "\tSkipped:" + totalConfigSkipped + "\n";
            }
            summary += "-----------------------------\n";


            summary = results.FailedTests.Aggregate(summary, (current, result) => current + ("FAILED : " + result.Method + " : " + (result.Exception == null ? null : result.Exception.Message) + "\n"));
            summary = results.SkippedTests.Aggregate(summary, (current, result) => current + ("SKIPPED : " + result.Method + " : " + (result.Exception == null ? null : result.Exception.Message) + "\n"));

            Console.WriteLine(summary);
        }
示例#3
0
        // TODO: repetition
        private void CreateDynamicTask(string parentGuid, ISuiteResult result)
        {
            var dynamicTask = new DynamicTask(typeof(TestTask), parentGuid, result.Identity, result.Text);

            _server.CreateDynamicElement(dynamicTask);
            Finished(result, dynamicTask);
        }
示例#4
0
        public Runner(Configuration config)
        {
            _suiteTimeout = config.SuiteTimeout;
            _maxThreads   = config.MaxThreads;
            _config       = config;

            _suiteResult = new SuiteResult("Test Run, " + DateTime.Now.ToString("dd/MM/yyyy HH:mm"));
            var testListeners = new List <ITestListner>
            {
                new ConsoleTestListener(config),
                new WebDriverTestListener(config),
                new BeforesuiteWebTestListner(config),
                new AfterSuiteWebTestListner(config)
            };

            if (!config.ExcludeFromReports && !string.IsNullOrEmpty(config.SeleneApiUrl) && SeleneTestListener.SeleneIsReachableSync(config.SeleneApiUrl))
            {
                testListeners.Add(new SeleneTestListener(config));
                SeSugar.Environment.Logger.LogLine("Connected to Scrummy.");
            }
            else
            {
                SeSugar.Environment.Logger.LogLine("Could not connect to Scrummy - web logging not enabled for this test run.");
            }

            _methodRunner = new MethodInstanceRunner(testListeners);

            foreach (var reporter in _config.Reporters)
            {
                var r = (IReporter)Activator.CreateInstance(reporter, _config.Output);
                _reporters.Add(r);
            }
        }
示例#5
0
        private void Finished(ISuiteResult result, Task task)
        {
            var operations = MergeSetupsAndCleanups(result);

            Finished(result, operations, result.OutputEntries, task);

            result.SuiteResults.Where(TaskDoesNotExist).ForEach(x => CreateDynamicTask(task.Id, x));
            result.TestResults.Where(TaskDoesNotExist).ForEach(x => CreateDynamicTask(task.Id, x));
        }
        public override void OnSuiteFinished(ISuiteResult result)
        {
            if (result.State == State.Failed && !result.SuiteResults.Any() && !result.TestResults.Any())
            {
                _writer.WriteTestFailed(result.Text, result.GetBriefSummary(), result.GetDetailedSummary(TextSymbolProvider.Instance));
            }

            _writer.WriteTestSuiteFinished(result.Text);
        }
示例#7
0
        public void GenerateReport(ISuiteResult results)
        {
            var dictionary = new Dictionary <string, List <ITestResult> >();

            foreach (var result in results.Results())
            {
                var attr = result.Instance.Attr;
                if (!dictionary.ContainsKey(attr.File))
                {
                    dictionary[attr.File] = new List <ITestResult>();
                }
                dictionary[attr.File].Add(result);
            }

            var writer = new XmlTextWriter(Output + "/" + ReportName, null)
            {
                Formatting = Formatting.Indented
            };

            writer.WriteStartElement("unitTest");
            writer.WriteAttributeString("version", "1");


            foreach (var file in dictionary.Keys)
            {
                writer.WriteStartElement("file");
                writer.WriteAttributeString("path", file);

                foreach (var result in dictionary[file])
                {
                    writer.WriteStartElement("testCase");
                    writer.WriteAttributeString("name", result.Instance.ToString() + result.Uuid);
                    writer.WriteAttributeString("duration", Math.Ceiling(result.Total.TotalMilliseconds).ToString());
                    if (result.Status != Status.Passed)
                    {
                        writer.WriteStartElement(MapToDesiredTag(result.Status));

                        if (result.Exception != null)
                        {
                            writer.WriteAttributeString("message", result.Exception.Message);
                            writer.WriteString(result.Exception.StackTrace);
                        }

                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }

            writer.WriteEndElement();
            writer.Close();
        }
示例#8
0
        public override void OnSuiteFinished(ISuiteResult result)
        {
            if (result.State == State.Failed && !result.SuiteResults.Any() && !result.TestResults.Any())
              {
            var operations = MergeSetupsAndCleanups(result).ToList();
            var exceptions = GetExceptions(operations).ToList();

            var message = GetGeneralMessage(exceptions, operations);
            var details = GetDetails(operations, result.OutputEntries);

            _writer.WriteTestFailed(result.Identity.Absolute, message, details);
              }

              _writer.WriteTestSuiteFinished(result.Identity.Absolute);
        }
示例#9
0
        public override void OnSuiteFinished(ISuiteResult result)
        {
            if (result.State == State.Failed && !result.SuiteResults.Any() && !result.TestResults.Any())
            {
                var operations = MergeSetupsAndCleanups(result).ToList();
                var exceptions = GetExceptions(operations).ToList();

                var message = GetGeneralMessage(exceptions, operations);
                var details = GetDetails(operations, result.OutputEntries);

                _writer.WriteTestFailed(result.Text, message, details);
            }

            _writer.WriteTestSuiteFinished(result.Text);
        }
示例#10
0
        private ISuiteResult RunWithResourcesAcquired(
            IIntent intent,
            ISuiteProvider provider,
            IEnumerable <Tuple <IIntent, ISuiteProvider> > suitePairs,
            IEnumerable <Tuple <IIntent, ITestProvider> > testPairs)
        {
            _listener.OnSuiteStarted(intent, provider.Text);

            IOutputRecording           outputRecording;
            IContextScope              contextScope;
            ICollection <ISuiteResult> suiteResults = new ISuiteResult[0];
            ICollection <ITestResult>  testResults  = new ITestResult[0];

            using (outputRecording = _resultFactory.CreateOutputRecording())
            {
                using (contextScope = _contextRunner.Run(provider.ContextProviders))
                {
                    if (contextScope.SetupResults.All(x => x.State == State.Passed))
                    {
                        suiteResults = suitePairs.AsParallel()
                                       .WithDegreeOfParallelism(degreeOfParallelism: 1)
                                       .WithCancellation(_cancellationTokenSource.Token)
                                       .Select(x => Run(x.Item1, x.Item2)).ToList();

                        testResults = testPairs.AsParallel()
                                      .WithDegreeOfParallelism(degreeOfParallelism: 1)
                                      .WithCancellation(_cancellationTokenSource.Token)
                                      .Select(x => _testRunner.Run(x.Item1, x.Item2)).ToList();
                    }
                }
            }

            var result = _resultFactory.CreateSuiteResult(
                provider,
                outputRecording,
                contextScope.SetupResults,
                contextScope.CleanupResults,
                suiteResults,
                testResults);

            _listener.OnSuiteFinished(result);

            return(result);
        }
示例#11
0
        public void GenerateReport(ISuiteResult results)
        {
            // produce the json data the report will need.
            var json  = JsonConvert.SerializeObject(results, Formatting.Indented);
            var jsonp = "var result = " + json;

            var file = new StreamWriter(Output + "/" + ReportName);

            file.Write(jsonp);
            file.Close();

            // copy the static files
            var assembly  = Assembly.GetExecutingAssembly();
            var resources = assembly.GetManifestResourceNames();

            foreach (var resource in resources)
            {
                CopyResource(resource, assembly);
            }
        }
示例#12
0
        public void GenerateReport(ISuiteResult results)
        {
            var dictionary = new Dictionary <string, List <ITestResult> >();

            foreach (var result in results.Results())
            {
                var attr = result.Instance.Attr;
                if (!dictionary.ContainsKey(attr.File))
                {
                    dictionary[attr.File] = new List <ITestResult>();
                }
                dictionary[attr.File].Add(result);
            }

            foreach (var file in dictionary.Keys)
            {
                foreach (var result in dictionary[file])
                {
                    TcpClient clientSocket = new TcpClient();
                    clientSocket.Connect(_serviceHostName, _servicePort);
                    NetworkStream serverStream = clientSocket.GetStream();
                    string        dataToSend   = "TestCaseName=" + result.Instance + ",TestId=" + result.Uuid + ",TestStatus=" + MapToDesiredTag(result.Status);
                    if (result.Status != Status.Passed)
                    {
                        dataToSend = dataToSend + ",TestMessage=" +
                                     result.Exception.Message + ",TestStacktrace=" + result.Exception.StackTrace;
                    }
                    else
                    {
                        dataToSend = dataToSend + ",TestMessage=NA,TestStacktrace=na";
                    }
                    dataToSend = dataToSend.Replace(Environment.NewLine, "");
                    byte[] outStream = Encoding.UTF8.GetBytes(dataToSend);
                    serverStream.Write(outStream, 0, outStream.Length);
                    serverStream.Flush();
                    clientSocket.Close();
                }
            }
        }
示例#13
0
 public override void OnSuiteFinished(ISuiteResult result)
 {
     Finished(result);
 }
示例#14
0
 public virtual void OnSuiteFinished(ISuiteResult result)
 {
 }
示例#15
0
 protected IEnumerable<IOperationResult> MergeSetupsAndCleanups(ISuiteResult result)
 {
     return result.SetupResults.Concat(new FillingOperationResult()).Concat(result.CleanupResults);
 }
示例#16
0
 public void GenerateReport(ISuiteResult results, Dictionary <string, List <ITestResult> > dictionary)
 {
     throw new NotImplementedException();
 }
示例#17
0
 public void OnSuiteFinished(ISuiteResult result)
 {
     _listeners.ForEach(x => x.OnSuiteFinished(result));
 }
 public void OnSuiteFinished(ISuiteResult result)
 {
     _listener.OnSuiteFinished(result);
 }
示例#19
0
 public virtual void OnSuiteFinished(ISuiteResult result)
 {
 }
示例#20
0
 public override void OnSuiteFinished(ISuiteResult result)
 {
     IfTaskExists(result, x => Finished(result, x));
 }
示例#21
0
 protected IEnumerable <IOperationResult> MergeSetupsAndCleanups(ISuiteResult result)
 {
     return(result.SetupResults.Concat(new FillingOperationResult()).Concat(result.CleanupResults));
 }
 public override void OnSuiteFinished (ISuiteResult result)
 {
   Finished(result, MergeSetupsAndCleanups(result), result.OutputEntries);
 }
示例#23
0
 public override void OnSuiteFinished(ISuiteResult result)
 {
     _listeners.ForEach(x => x.OnSuiteFinished(result));
 }
示例#24
0
 public void OnSuiteFinished(ISuiteResult result)
 {
     _listener.OnSuiteFinished(result);
 }