public void WorkflowCoverageReports_TryExecute_GetTotalCoverage_Given_SomethingFails_ShouldContinue() { var sdf = Guid.NewGuid(); var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>(); mockWarewolfWorkflow.Setup(o => o.WorkflowNodes) .Throws(new Exception("false exception: this should be logged into serverlog")); var sut = new WorkflowCoverageReports(mockWarewolfWorkflow.Object); var result = sut.TryExecute(); //prints to serverlog on fail Assert.IsNull(result); }
public IServiceTestCoverageModelTo New(Guid workflowId, ICoverageArgs args, List <IServiceTestModelTO> serviceTestModelTos) { var workflow = _resourceCatalog.GetWorkflow(workflowId); var coverageReports = new WorkflowCoverageReports(workflow); var coverageModelTo = new ServiceTestCoverageModelTo { WorkflowId = workflowId, OldReportName = args?.OldReportName, ReportName = args?.ReportName, LastRunDate = DateTime.Now, AllTestNodesCovered = serviceTestModelTos .Select(test => new SingleTestNodesCovered(test.TestName, test.TestSteps)) .ToArray() }; coverageReports.Add(coverageModelTo); var coverageReportsTO = coverageReports.TryExecute(); coverageModelTo.TotalCoverage = coverageReportsTO.TotalCoverage; coverageModelTo.AllWorkflowNodes = coverageReportsTO.WorkflowNodes; coverageModelTo.NotCoveredNodesCount = coverageReportsTO.NotCoveredNodesCount; return(coverageModelTo); }
public void WorkflowCoverageReports_TryExecute_GetTotalCoverage_Given_ShouldSuccess() { var sdf = Guid.NewGuid(); var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>(); mockWarewolfWorkflow.Setup(o => o.WorkflowNodes).Returns(new List <IWorkflowNode> { new WorkflowNode { ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"), UniqueID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"), }, new WorkflowNode { ActivityID = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"), UniqueID = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"), }, new WorkflowNode { ActivityID = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"), UniqueID = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"), } }); var sut = new WorkflowCoverageReports(mockWarewolfWorkflow.Object); //passing test sut.Add(new ServiceTestCoverageModelTo { WorkflowId = Guid.NewGuid(), LastRunDate = DateTime.Now, OldReportName = "passing test old name", ReportName = "passing test new name", TotalCoverage = .25, AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep> { new ServiceTestStepTO { ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"), UniqueID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"), Type = StepType.Assert, Result = new TestRunResult { RunTestResult = RunResult.TestPassed } } }) } }); //add invalid test sut.Add(new ServiceTestCoverageModelTo { WorkflowId = Guid.NewGuid(), LastRunDate = DateTime.Now, OldReportName = "invalid test old name", ReportName = "invalid test new name", TotalCoverage = 0, AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep> { new ServiceTestStepTO { //this makes for invalid test }, new ServiceTestStepTO { ActivityID = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"), UniqueID = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"), Type = StepType.Mock, Result = new TestRunResult { RunTestResult = RunResult.TestInvalid } } }) } }); //failing test sut.Add(new ServiceTestCoverageModelTo { WorkflowId = Guid.NewGuid(), LastRunDate = DateTime.Now, OldReportName = "failing test old name", ReportName = "failing test new name", TotalCoverage = 0.1, AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep> { new ServiceTestStepTO { ActivityID = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"), UniqueID = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"), Type = StepType.Assert, Result = new TestRunResult { RunTestResult = RunResult.TestFailed } } }) } }); var result = sut.TryExecute(); Assert.IsNotNull(result.Resource); Assert.IsTrue(result.HasTestReports); Assert.AreEqual(1, result.TotalCoverage, "design change: mocked nodes should now included with the test coverage calculation"); }