public string Setup() { const string OUTPUT_DIRECTORY = FileSystemPrefix + @"JSONFeatureOutput"; const string ROOT_PATH = FileSystemPrefix + @"JSON\Features"; const string testResultFilePath = FileSystemPrefix + @"JSON\results-example-failing-and-pasing-mstest.trx"; string filePath = FileSystem.Path.Combine(OUTPUT_DIRECTORY, JSONDocumentationBuilder.JsonFileName); AddFakeFolderAndFiles("JSON", new[] { "results-example-failing-and-pasing-mstest.trx" }); AddFakeFolderAndFiles( @"JSON\Features", new[] { "OneScenarioTransferingMoneyBetweenAccountsFailing.feature", "TransferBetweenAccounts_WithSuccess.feature", "TwoScenariosTransferingFundsOneFailingOneSuccess.feature", "TwoScenariosTransferingMoneyBetweenAccoutsWithSuccess.feature", }); var resultFile = RetrieveContentOfFileFromResources(ResourcePrefix + "JSON.results-example-failing-and-pasing-mstest.trx"); FileSystem.AddFile(testResultFilePath, resultFile); GeneralTree<INode> features = Container.Resolve<DirectoryTreeCrawler>().Crawl(ROOT_PATH); var outputDirectory = FileSystem.DirectoryInfo.FromDirectoryName(OUTPUT_DIRECTORY); if (!outputDirectory.Exists) outputDirectory.Create(); var configuration = new Configuration() { OutputFolder = FileSystem.DirectoryInfo.FromDirectoryName(OUTPUT_DIRECTORY), DocumentationFormat = DocumentationFormat.JSON, TestResultsFormat = TestResultsFormat.MsTest, SystemUnderTestName = "SUT Name", SystemUnderTestVersion = "SUT Version" }; configuration.AddTestResultFile(FileSystem.FileInfo.FromFileName(testResultFilePath)); ITestResults testResults = new MsTestResults(configuration); var jsonDocumentationBuilder = new JSONDocumentationBuilder(configuration, testResults, FileSystem); jsonDocumentationBuilder.Build(features); string content = FileSystem.File.ReadAllText(filePath); return content; }
public void Setup() { if (File.Exists(this.testResultFilePath) == false) { throw new FileNotFoundException("File " + this.testResultFilePath + " was not found"); } GeneralTree<IDirectoryTreeNode> features = Container.Resolve<DirectoryTreeCrawler>().Crawl(ROOT_PATH); var outputDirectory = new DirectoryInfo(OUTPUT_DIRECTORY); if (!outputDirectory.Exists) outputDirectory.Create(); var configuration = new Configuration { OutputFolder = new DirectoryInfo(OUTPUT_DIRECTORY), DocumentationFormat = DocumentationFormat.JSON, TestResultsFile = new FileInfo(this.testResultFilePath), TestResultsFormat = TestResultsFormat.MsTest }; ITestResults testResults = new MsTestResults(configuration); var jsonDocumentationBuilder = new JSONDocumentationBuilder(configuration, testResults); jsonDocumentationBuilder.Build(features); }