public void ShouldUploadHumanReadableWhenCompareToDashboardEnabled() { // Arrange var reporters = new string[1]; reporters[0] = "dashboard"; var options = new StrykerOptions( dashboardApiKey: "Acces_Token", projectName: "github.com/JohnDoe/project", projectVersion: "version/human/readable", reporters: reporters ); var dashboardClientMock = new Mock <IDashboardClient>(); dashboardClientMock.Setup(x => x.PublishReport(It.IsAny <string>(), "version/human/readable")); var branchProviderMock = new Mock <IGitInfoProvider>(); var target = new DashboardReporter(options, dashboardClient: dashboardClientMock.Object); // Act target.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith().ToReadOnlyInputComponent()); // Assert dashboardClientMock.Verify(x => x.PublishReport(It.IsAny <string>(), "version/human/readable"), Times.Once); }
public void LogsDebugWhenBaselineUploadedSuccesfull() { // Arrange var reporters = new string[1]; reporters[0] = "dashboard"; var options = new StrykerOptions( compareToDashboard: true, dashboardApiKey: "Acces_Token", projectName: "github.com/JohnDoe/project", projectVersion: "version/human/readable", reporters: reporters) { }; var loggerMock = new Mock <ILogger <DashboardReporter> >(MockBehavior.Loose); var dashboardClientMock = new Mock <IDashboardClient>(MockBehavior.Loose); var branchProviderMock = new Mock <IGitInfoProvider>(); var chalkMock = new Mock <IChalk>(); branchProviderMock.Setup(x => x.GetCurrentBranchName()).Returns("refs/heads/master"); dashboardClientMock.Setup(x => x.PublishReport(It.IsAny <string>(), "dashboard-compare/refs/heads/master")).ReturnsAsync("http://www.example.com/baseline"); dashboardClientMock.Setup(x => x.PublishReport(It.IsAny <string>(), "version/human/readable")).ReturnsAsync("http://www.example.com/humanreadable"); var target = new DashboardReporter(options, dashboardClient: dashboardClientMock.Object, branchProvider: branchProviderMock.Object, loggerMock.Object, chalkMock.Object); // Act target.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); // Assert loggerMock.Verify(x => x.Log(LogLevel.Debug, It.IsAny <EventId>(), It.Is <It.IsAnyType>((v, t) => true), It.IsAny <Exception>(), It.Is <Func <It.IsAnyType, Exception, string> >((v, t) => true))); chalkMock.Verify(x => x.Green(It.Is <string>(s => s == "Your stryker report has been uploaded to: \n http://www.example.com/humanreadable \nYou can open it in your browser of choice."))); }
public void ShouldNotOpenDashboardReportIfOptionIsProvided(ReportType?reportType) { var reporters = new[] { Reporter.Dashboard }; var options = new StrykerOptions { ReportTypeToOpen = reportType, DashboardApiKey = "Access_Token", ProjectName = "github.com/JohnDoe/project", ProjectVersion = "version/human/readable", Reporters = reporters }; var mockProcess = new Mock <IWebbrowserOpener>(); var dashboardClientMock = new Mock <IDashboardClient>(); dashboardClientMock.Setup(x => x.PublishReport(It.IsAny <JsonReport>(), "version/human/readable")) .Returns(Task.FromResult("https://dashboard.com")); var reporter = new DashboardReporter(options, dashboardClientMock.Object, processWrapper: mockProcess.Object); var mutationTree = JsonReportTestHelper.CreateProjectWith(); reporter.OnAllMutantsTested(mutationTree); // Check if browser open action is invoked mockProcess.VerifyNoOtherCalls(); }
public void ShouldCallUploadBaselineAndHumanReadableWhenCompareToDashboardEnabled() { // Arrange var reporters = new string[1]; reporters[0] = "dashboard"; var options = new StrykerOptions( compareToDashboard: true, dashboardApiKey: "Acces_Token", projectName: "github.com/JohnDoe/project", projectVersion: "version/human/readable", reporters: reporters) { }; var dashboardClientMock = new Mock <IDashboardClient>(MockBehavior.Loose); var branchProviderMock = new Mock <IGitInfoProvider>(); branchProviderMock.Setup(x => x.GetCurrentBranchName()).Returns("refs/heads/master"); var target = new DashboardReporter(options, dashboardClient: dashboardClientMock.Object, branchProvider: branchProviderMock.Object); // Act target.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); // Assert dashboardClientMock.Verify(x => x.PublishReport(It.IsAny <string>(), "dashboard-compare/refs/heads/master"), Times.Once); dashboardClientMock.Verify(x => x.PublishReport(It.IsAny <string>(), "version/human/readable"), Times.Once); }
public void ShouldUploadHumanReadableWhenCompareToDashboardEnabled() { // Arrange var reporters = new[] { Reporter.Dashboard }; var options = new StrykerOptions { DashboardApiKey = "Access_Token", ProjectName = "github.com/JohnDoe/project", ProjectVersion = "version/human/readable", Reporters = reporters }; var mockProcess = new Mock <IWebbrowserOpener>(); var dashboardClientMock = new Mock <IDashboardClient>(); dashboardClientMock.Setup(x => x.PublishReport(It.IsAny <JsonReport>(), "version/human/readable")); var branchProviderMock = new Mock <IGitInfoProvider>(); var target = new DashboardReporter(options, dashboardClient: dashboardClientMock.Object, processWrapper: mockProcess.Object); // Act target.OnAllMutantsTested(JsonReportTestHelper.CreateProjectWith()); // Assert dashboardClientMock.Verify(x => x.PublishReport(It.IsAny <JsonReport>(), "version/human/readable"), Times.Once); }