public void JsonReport_ThresholdsAreSet() { var folderComponent = JsonReportTestHelper.CreateProjectWith(); var report = JsonReport.Build(new StrykerOptions(), folderComponent); report.ShouldSatisfyAllConditions( () => report.Thresholds.ShouldContainKey("high"), () => report.Thresholds.ShouldContainKey("low")); }
public void JsonReport_BuildReportReturnsSingletonJsonReport() { var folderComponent = JsonReportTestHelper.CreateProjectWith(); var options = new StrykerOptions(); var firstReport = JsonReport.Build(options, folderComponent.ToReadOnlyInputComponent()); var secondReport = JsonReport.Build(options, folderComponent.ToReadOnlyInputComponent()); secondReport.ShouldBe(firstReport); }
public void JsonReporter_OnAllMutantsTestedShouldWriteJsonToFile() { var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions(thresholdBreak: 0, thresholdHigh: 80, thresholdLow: 60); var reporter = new JsonReporter(options, mockFileSystem); reporter.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.json"); mockFileSystem.FileExists(reportPath).ShouldBeTrue($"Path {reportPath} should exist but it does not."); }
public void JsonReportFileComponents_ShouldContainMutants() { var folderComponent = JsonReportTestHelper.CreateProjectWith(); foreach (var file in (folderComponent as FolderComposite).GetAllFiles()) { var jsonReportComponent = new JsonReportFileComponent(file); foreach (var mutant in file.Mutants) { jsonReportComponent.Mutants.ShouldContain(m => m.Id == mutant.Id); } } }
public void JsonReportFileComponents_ShouldContainMutants() { var folderComponent = JsonReportTestHelper.CreateProjectWith(); foreach (var file in (folderComponent as CsharpFolderComposite).GetAllFiles()) { var jsonReportComponent = new JsonReportFileComponent(((CsharpFileLeaf)file).ToReadOnly()); foreach (var mutant in file.Mutants) { jsonReportComponent.Mutants.ShouldContain(m => m.Id == mutant.Id.ToString()); } } }
public void JsonReporter_OnAllMutantsTestedShouldContainJsonReport() { var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions(thresholdBreak: 0, thresholdHigh: 80, thresholdLow: 60); var reporter = new HtmlReporter(options, mockFileSystem); reporter.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith().ToReadOnlyInputComponent()); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.html"); var fileContents = mockFileSystem.GetFile(reportPath).TextContents; JsonReport.Build(options, null).ToJson().ShouldBeSubsetOf(fileContents); }
public void JsonReportFileComponent_DoesNotContainDuplicateMutants() { var loggerMock = Mock.Of <ILogger>(); var folderComponent = JsonReportTestHelper.CreateProjectWith(duplicateMutant: true); foreach (var file in (folderComponent as FolderComposite).GetAllFiles()) { var jsonReportComponent = new JsonReportFileComponent(file, loggerMock); foreach (var mutant in file.Mutants) { jsonReportComponent.Mutants.ShouldContain(m => m.Id == mutant.Id); } } }
public void JsonReporter_OnAllMutantsTestedShouldReplacePlaceholdersInHtmlFile() { var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions(thresholdBreak: 0, thresholdHigh: 80, thresholdLow: 60); var reporter = new HtmlReporter(options, mockFileSystem); reporter.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith().ToReadOnlyInputComponent()); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.html"); var fileContents = mockFileSystem.GetFile(reportPath).TextContents; fileContents.ShouldSatisfyAllConditions( () => fileContents.ShouldNotContain("##REPORT_JS##"), () => fileContents.ShouldNotContain("##REPORT_TITLE##"), () => fileContents.ShouldNotContain("##REPORT_JSON##")); }
public void ShouldNotOpenHtmlReportIfOptionIsProvided(ReportType?reportType) { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { ReportTypeToOpen = reportType, OutputPath = Directory.GetCurrentDirectory() }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); var mutationTree = JsonReportTestHelper.CreateProjectWith(); reporter.OnAllMutantsTested(mutationTree); // Check if browser open action is invoked mockProcess.VerifyNoOtherCalls(); }
public void ShouldWriteJsonToFile() { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { Thresholds = new Thresholds { High = 80, Low = 60, Break = 0 }, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); reporter.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.html"); mockFileSystem.FileExists(reportPath).ShouldBeTrue($"Path {reportPath} should exist but it does not."); }
public void JsonReporter_OnAllMutantsTestedShouldWriteJsonToFile() { var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { Thresholds = new Thresholds { High = 80, Low = 60, Break = 0 }, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new JsonReporter(options, mockFileSystem); reporter.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.json"); mockFileSystem.FileExists(reportPath).ShouldBeTrue($"Path {reportPath} should exist but it does not."); var fileContents = mockFileSystem.File.ReadAllText(reportPath); fileContents.ShouldContain(@"""thresholds"":{"); fileContents.ShouldContain(@"""high"":80"); fileContents.ShouldContain(@"""low"":60"); }
public void ShouldOpenHtmlReportIfOptionIsProvided() { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { ReportTypeToOpen = ReportType.Html, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); var mutationTree = JsonReportTestHelper.CreateProjectWith(); reporter.OnAllMutantsTested(mutationTree); var reportUri = Path.Combine(options.OutputPath, "reports", $"{options.ReportFileName}.html"); reportUri = reportUri.Replace("\\", "/"); reportUri = reportUri.StartsWith("/") ? reportUri : "/" + reportUri; // Check if browser open action is invoked mockProcess.Verify(m => m.Open("file://" + reportUri)); }
public void ShouldReplacePlaceholdersInHtmlFile() { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { Thresholds = new Thresholds { High = 80, Low = 60, Break = 0 }, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); reporter.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.html"); var fileContents = mockFileSystem.GetFile(reportPath).TextContents; fileContents.ShouldNotContain("##REPORT_JS##"); fileContents.ShouldNotContain("##REPORT_TITLE##"); fileContents.ShouldNotContain("##REPORT_JSON##"); }
public void ShouldContainJsonInHtmlReportFile() { var mockProcess = new Mock <IWebbrowserOpener>(); var mockFileSystem = new MockFileSystem(); var options = new StrykerOptions { Thresholds = new Thresholds { High = 80, Low = 60, Break = 0 }, OutputPath = Directory.GetCurrentDirectory(), ReportFileName = "mutation-report" }; var reporter = new HtmlReporter(options, mockFileSystem, processWrapper: mockProcess.Object); var mutationTree = JsonReportTestHelper.CreateProjectWith(); reporter.OnAllMutantsTested(mutationTree); var reportPath = Path.Combine(options.OutputPath, "reports", $"mutation-report.html"); var fileContents = mockFileSystem.GetFile(reportPath).TextContents; fileContents.ShouldContain(@"""thresholds"":{"); fileContents.ShouldContain(@"""high"":80"); fileContents.ShouldContain(@"""low"":60"); }