Beispiel #1
0
        private static void ApplyTestResultsToFeatures(IContainer container, IConfiguration configuration, GeneralTree <INode> features)
        {
            var testResults = container.Resolve <ITestResults>();

            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                var featureTreeNode = node as FeatureNode;
                if (featureTreeNode == null)
                {
                    return;
                }

                if (configuration.HasTestResults)
                {
                    SetResultsAtFeatureLevel(featureTreeNode, testResults);
                    SetResultsForIndividualScenariosUnderFeature(featureTreeNode, testResults);
                }
                else
                {
                    featureTreeNode.Feature.Result = TestResult.Inconclusive;
                }
            });

            features.AcceptVisitor(actionVisitor);
        }
Beispiel #2
0
        public void Build(GeneralTree <INode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.Info("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);


            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                if (node.IsIndexMarkDownNode())
                {
                    return;
                }

                string nodePath =
                    this.fileSystem.Path.Combine(
                        this.configuration.OutputFolder.
                        FullName,
                        node.RelativePathFromRoot);
                string htmlFilePath;

                if (node.IsContent)
                {
                    htmlFilePath =
                        nodePath.Replace(
                            this.fileSystem.Path.GetExtension(nodePath),
                            ".html");
                }
                else
                {
                    this.fileSystem.Directory.CreateDirectory(nodePath);

                    htmlFilePath = this.fileSystem.Path.Combine(nodePath,
                                                                "index.html");
                }

                using (
                    var writer =
                        new System.IO.StreamWriter(htmlFilePath,
                                                   false,
                                                   Encoding.UTF8))
                {
                    XDocument document =
                        this.htmlDocumentFormatter.Format(
                            node, features,
                            this.configuration.FeatureFolder);
                    document.Save(writer);
                    writer.Close();
                }
            });

            if (features != null)
            {
                features.AcceptVisitor(actionVisitor);
            }
        }
        public void Build(GeneralTree <IDirectoryTreeNode> features)
        {
            string filename = string.IsNullOrEmpty(configuration.SystemUnderTestName)
                                  ? "features.docx"
                                  : configuration.SystemUnderTestName + ".docx";
            string documentFileName = Path.Combine(configuration.OutputFolder.FullName, filename);

            if (File.Exists(documentFileName))
            {
                File.Delete(documentFileName);
            }

            using (
                WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Create(documentFileName,
                                                                                              WordprocessingDocumentType
                                                                                              .Document))
            {
                MainDocumentPart mainDocumentPart = wordProcessingDocument.AddMainDocumentPart();
                wordStyleApplicator.AddStylesPartToPackage(wordProcessingDocument);
                wordStyleApplicator.AddStylesWithEffectsPartToPackage(wordProcessingDocument);
                wordFontApplicator.AddFontTablePartToPackage(wordProcessingDocument);
                var documentSettingsPart = mainDocumentPart.AddNewPart <DocumentSettingsPart>();
                documentSettingsPart.Settings = new Settings();
                wordHeaderFooterFormatter.ApplyHeaderAndFooter(wordProcessingDocument);

                var document = new Document();
                var body     = new Body();
                document.Append(body);

                var actionVisitor = new ActionVisitor <IDirectoryTreeNode>(node =>
                {
                    var featureDirectoryTreeNode =
                        node as FeatureDirectoryTreeNode;
                    if (featureDirectoryTreeNode != null)
                    {
                        wordFeatureFormatter.Format(body,
                                                    featureDirectoryTreeNode);
                    }
                });

                features.AcceptVisitor(actionVisitor);

                mainDocumentPart.Document = document;
                mainDocumentPart.Document.Save();
            }

            // HACK - Add the table of contents
            using (WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Open(documentFileName, true))
            {
                XElement firstPara = wordProcessingDocument
                                     .MainDocumentPart
                                     .GetXDocument()
                                     .Descendants(W.p)
                                     .FirstOrDefault();

                TocAdder.AddToc(wordProcessingDocument, firstPara, @"TOC \o '1-2' \h \z \u", null, 4);
            }
        }
        public void Build(GeneralTree <INode> features)
        {
            if (Log.IsInfoEnabled)
            {
                Log.Info("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);

            var actionVisitor = new ActionVisitor <INode>(node => this.VisitNodes(features, node));

            features?.AcceptVisitor(actionVisitor);
        }
        public void Build(GeneralTree<INode> features)
        {
            if (log.IsInfoEnabled)
            {
              log.Info("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);


            var actionVisitor = new ActionVisitor<INode>(node => this.VisitNodes(features, node));
            if (features != null)
                features.AcceptVisitor(actionVisitor);
        }
Beispiel #6
0
        public void Build(GeneralTree <INode> features)
        {
            this.ditaMapBuilder.Build(features);

            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                var featureDirectoryTreeNode =
                    node as FeatureNode;
                if (featureDirectoryTreeNode != null)
                {
                    this.ditaFeatureFormatter.Format(
                        featureDirectoryTreeNode);
                }
            });

            features.AcceptVisitor(actionVisitor);
        }
        public void Build(GeneralTree<IDirectoryTreeNode> features)
        {
            this.ditaMapBuilder.Build(features);

            var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
                                                                          {
                                                                              var featureDirectoryTreeNode =
                                                                                  node as FeatureDirectoryTreeNode;
                                                                              if (featureDirectoryTreeNode != null)
                                                                              {
                                                                                  this.ditaFeatureFormatter.Format(
                                                                                      featureDirectoryTreeNode);
                                                                              }
                                                                          });

            features.AcceptVisitor(actionVisitor);
        }
Beispiel #8
0
        private static void ApplyTestResultsToFeatures(IContainer container, Configuration configuration, GeneralTree<INode> features)
        {
            var testResults = container.Resolve<ITestResults>();

            var actionVisitor = new ActionVisitor<INode>(node =>
                {
                    var featureTreeNode = node as FeatureNode;
                    if (featureTreeNode == null) return;
                    if (configuration.HasTestResults)
                    {
                        SetResultsAtFeatureLevel(featureTreeNode, testResults);
                        SetResultsForIndividualScenariosUnderFeature(featureTreeNode, testResults);
                    }
                    else
                    {
                        featureTreeNode.Feature.Result = TestResult.Inconclusive();
                    }
                });

            features.AcceptVisitor(actionVisitor);
        }
        public void Build(GeneralTree<IDirectoryTreeNode> features)
        {   
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);

            var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
                {
                  if (node.IsIndexMarkDownNode())
                  {
                    return;
                  }

                    var nodePath = Path.Combine(this.configuration.OutputFolder.FullName, node.RelativePathFromRoot);
                  string htmlFilePath;

                    if (node.IsContent)
                    {
                        htmlFilePath = nodePath.Replace(Path.GetExtension(nodePath), ".html");
                    }
                    else
                    {
                        Directory.CreateDirectory(nodePath);

                        htmlFilePath = Path.Combine(nodePath, "index.html");
                    }

                    using (var writer = new StreamWriter(htmlFilePath, false, Encoding.UTF8))
                    {
                      var document = this.htmlDocumentFormatter.Format(node, features, this.configuration.FeatureFolder);
                      document.Save(writer);
                      writer.Close();
                    }
                });

            features.AcceptVisitor(actionVisitor);
        }
        public void Build(GeneralTree <INode> features)
        {
            if (Log.IsInfoEnabled)
            {
                Log.Info("Writing Cucumber to {0}", this.configuration.OutputFolder.FullName);
            }

            List <Feature> featuresToFormat = new List <Feature>();

            ActionVisitor <INode> actionVisitor = new ActionVisitor <INode>(node =>
            {
                FeatureNode featureTreeNode = node as FeatureNode;
                if (featureTreeNode != null)
                {
                    featuresToFormat.Add(featureTreeNode.Feature);
                }
            });

            features.AcceptVisitor(actionVisitor);

            this.CreateFile(this.OutputFilePath, this.GenerateJson(featuresToFormat));
        }
        public void Build(GeneralTree <INode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.Info("Writing JSON to {0}", this.configuration.OutputFolder.FullName);
            }

            var featuresToFormat = new List <FeatureWithMetaInfo>();

            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                var featureTreeNode =
                    node as FeatureNode;
                if (featureTreeNode != null)
                {
                    if (this.configuration.HasTestResults)
                    {
                        featuresToFormat.Add(
                            new FeatureWithMetaInfo(
                                featureTreeNode,
                                this.testResults.
                                GetFeatureResult(
                                    featureTreeNode.
                                    Feature)));
                    }
                    else
                    {
                        featuresToFormat.Add(
                            new FeatureWithMetaInfo(
                                featureTreeNode));
                    }
                }
            });

            features.AcceptVisitor(actionVisitor);

            CreateFile(this.OutputFilePath, GenerateJSON(featuresToFormat));
        }
        public void Build(GeneralTree <IDirectoryTreeNode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Writing Excel workbook to {0}", configuration.OutputFolder.FullName);
            }

            string spreadsheetPath = Path.Combine(configuration.OutputFolder.FullName, "features.xlsx");

            using (var workbook = new XLWorkbook())
            {
                var actionVisitor = new ActionVisitor <IDirectoryTreeNode>(node =>
                {
                    var featureDirectoryTreeNode =
                        node as FeatureDirectoryTreeNode;
                    if (featureDirectoryTreeNode != null)
                    {
                        IXLWorksheet worksheet =
                            workbook.AddWorksheet(
                                excelSheetNameGenerator.
                                GenerateSheetName(
                                    workbook,
                                    featureDirectoryTreeNode
                                    .Feature));
                        excelFeatureFormatter.Format(
                            worksheet,
                            featureDirectoryTreeNode.
                            Feature);
                    }
                });

                features.AcceptVisitor(actionVisitor);

                excelTableOfContentsFormatter.Format(workbook, features);

                workbook.SaveAs(spreadsheetPath);
            }
        }
        public void Build(GeneralTree<IDirectoryTreeNode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Writing Excel workbook to {0}", this.configuration.OutputFolder.FullName);
            }

            string spreadsheetPath = Path.Combine(this.configuration.OutputFolder.FullName, "features.xlsx");
            using (var workbook = new XLWorkbook())
            {
                var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
                                                                              {
                                                                                  var featureDirectoryTreeNode =
                                                                                      node as FeatureDirectoryTreeNode;
                                                                                  if (featureDirectoryTreeNode != null)
                                                                                  {
                                                                                      IXLWorksheet worksheet =
                                                                                          workbook.AddWorksheet(
                                                                                              this.excelSheetNameGenerator.
                                                                                                  GenerateSheetName(
                                                                                                      workbook,
                                                                                                      featureDirectoryTreeNode
                                                                                                          .Feature));
                                                                                      this.excelFeatureFormatter.Format(
                                                                                          worksheet,
                                                                                          featureDirectoryTreeNode.
                                                                                              Feature);
                                                                                  }
                                                                              });

                features.AcceptVisitor(actionVisitor);

                this.excelTableOfContentsFormatter.Format(workbook, features);

                workbook.SaveAs(spreadsheetPath);
            }
        }
        public void Build(GeneralTree<INode> features)
        {
            string filename = string.IsNullOrEmpty(this.configuration.SystemUnderTestName)
                ? "features.docx"
                : this.configuration.SystemUnderTestName + ".docx";
            string documentFileName = this.fileSystem.Path.Combine(this.configuration.OutputFolder.FullName, filename);
            if (this.fileSystem.File.Exists(documentFileName))
            {
                try
                {
                    this.fileSystem.File.Delete(documentFileName);
                }
                catch (System.IO.IOException ex)
                {
                    Log.Error("Cannot delete Word file. Is it still open in Word?", ex);
                    return;
                }
            }

            using (
                WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Create(
                    documentFileName,
                    WordprocessingDocumentType.Document))
            {
                MainDocumentPart mainDocumentPart = wordProcessingDocument.AddMainDocumentPart();
                this.wordStyleApplicator.AddStylesPartToPackage(wordProcessingDocument);
                this.wordStyleApplicator.AddStylesWithEffectsPartToPackage(wordProcessingDocument);
                this.wordFontApplicator.AddFontTablePartToPackage(wordProcessingDocument);
                var documentSettingsPart = mainDocumentPart.AddNewPart<DocumentSettingsPart>();
                documentSettingsPart.Settings = new Settings();
                this.wordHeaderFooterFormatter.ApplyHeaderAndFooter(wordProcessingDocument);

                var document = new Document();
                var body = new Body();
                document.Append(body);

                var actionVisitor = new ActionVisitor<INode>(node =>
                {
                    var featureDirectoryTreeNode =
                        node as FeatureNode;
                    if (featureDirectoryTreeNode != null)
                    {
                        this.wordFeatureFormatter.Format(body, featureDirectoryTreeNode);
                    }
                });

                features.AcceptVisitor(actionVisitor);

                mainDocumentPart.Document = document;
                mainDocumentPart.Document.Save();
            }

            // HACK - Add the table of contents
            using (WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Open(documentFileName, true))
            {
                XElement firstPara = wordProcessingDocument
                    .MainDocumentPart
                    .GetXDocument()
                    .Descendants(W.p)
                    .FirstOrDefault();

                TocAdder.AddToc(wordProcessingDocument, firstPara, @"TOC \o '1-2' \h \z \u", null, 4);
            }
        }
        public void Build(GeneralTree<INode> features)
        {
            if (log.IsInfoEnabled)
            {
              log.Info("Writing JSON to {0}", this.configuration.OutputFolder.FullName);
            }

            var featuresToFormat = new List<FeatureWithMetaInfo>();

            var actionVisitor = new ActionVisitor<INode>(node =>
                                                                          {
                                                                              var featureTreeNode =
                                                                                  node as FeatureNode;
                                                                              if (featureTreeNode != null)
                                                                              {
                                                                                  if (this.configuration.HasTestResults)
                                                                                  {
                                                                                      featuresToFormat.Add(
                                                                                          new FeatureWithMetaInfo(
                                                                                              featureTreeNode,
                                                                                              this.testResults.
                                                                                                  GetFeatureResult(
                                                                                                      featureTreeNode.
                                                                                                          Feature)));
                                                                                  }
                                                                                  else
                                                                                  {
                                                                                      featuresToFormat.Add(
                                                                                          new FeatureWithMetaInfo(
                                                                                              featureTreeNode));
                                                                                  }
                                                                              }
                                                                          });

            features.AcceptVisitor(actionVisitor);

            CreateFile(this.OutputFilePath, GenerateJSON(featuresToFormat));
        }