private TestOutcomes withRootOutcomes(TestOutcomes rootOutcomes) { return new TestOutcomes(this.outcomes, this.estimatedAverageStepCount, this.label, rootOutcomes, environmentVariables); }
private int countStepsWithResult(TestResult expectedResult, TestType testType) { int stepCount = outcomes.stream() .mapToInt(outcome -> outcome.countNestedStepsWithResult(expectedResult, testType)) .sum(); if ((stepCount == 0) && aMatchingTestExists(expectedResult, testType)) { return (int) Math.round(getAverageTestSize()); } return stepCount; }
public OutcomeCounter getTotalTests() { return count(TestType.ANY); }
public Double withIndeterminateResult() { int pendingCount = countTestsWithResult(TestResult.PENDING, testType); int ignoredCount = countTestsWithResult(TestResult.IGNORED, testType); int skippedCount = countTestsWithResult(TestResult.SKIPPED, testType); return (getTotal() == 0) ? 0 : ((pendingCount + skippedCount + ignoredCount) / (double) getTotal()); } public Double withFailureOrError() {
private Integer getEstimatedTotalStepCount() { int estimatedTotalSteps = (getStepCount() + estimatedUnimplementedStepCount()); return (estimatedTotalSteps == 0) ? DEFAULT_ESTIMATED_TOTAL_STEPS : estimatedTotalSteps; }
private TestResult testResultFor(Requirement req) { if (testOutcomes.forRequirement(req).getOutcomes().isEmpty()) { return TestResult.UNDEFINED; } return testOutcomes.forRequirement(req).getResult(); } }
private Element buildTestSuiteElement(Document doc, String testCaseName, TestOutcomes testCaseOutcomes) { int errors = testCaseOutcomes.count(TestType.ANY).withResult(TestResult.ERROR); int failures = testCaseOutcomes.count(TestType.ANY).withResult(TestResult.FAILURE); int success = testCaseOutcomes.count(TestType.ANY).withResult(TestResult.SUCCESS); int skipped = testCaseOutcomes.getTotal() - errors - failures - success; Element testSuiteElement = doc.createElement("testsuite"); testSuiteElement.setAttribute("name", testCaseName); testSuiteElement.setAttribute("time", Double.toString(testCaseOutcomes.getDurationInSeconds())); testSuiteElement.setAttribute("tests", Integer.toString(testCaseOutcomes.getTestCount())); testSuiteElement.setAttribute("errors", Integer.toString(errors)); testSuiteElement.setAttribute("skipped", Integer.toString(skipped)); testSuiteElement.setAttribute("failures", Integer.toString(failures)); testCaseOutcomes.getStartTime().ifPresent( startTime -> testSuiteElement.setAttribute("timestamp", TIMESTAMP_FORMAT.format(startTime)) ); return testSuiteElement; } }
private List<Release> extractReleasesFromTestOutcomeAnnotations(TestOutcomes testOutcomes) { List<Release> releases = Lists.newArrayList(); List<TestTag> releaseTags = testOutcomes.findMatchingTags() .withType("version") .withNameIn(matchingNames(releaseTypes.get(0))) .list(); for (TestTag tag : releaseTags) { releases.add(extractReleaseFor(tag, testOutcomes.withTag(tag), 1, NO_PARENTS)); } return releases; }
private void buildRequirements(List<RequirementOutcome> outcomes, List<RequirementsTagProvider> requirementsTagProviders, Requirement requirement) { TestOutcomes outcomesForRequirement = testOutcomes.forRequirement(requirement); int requirementsWithoutTests = countRequirementsWithoutTestsIn(requirement); int estimatedUnimplementedTests = requirementsWithoutTests * estimatedTestsPerRequirement(); outcomes.add(new RequirementOutcome(requirement, outcomesForRequirement, requirementsWithoutTests, estimatedUnimplementedTests, issueTracking)); }
private boolean isTested(Requirement childRequirement) { return !testOutcomes.forRequirement(childRequirement).getOutcomes().isEmpty(); }
private Integer estimatedUnimplementedStepCount() { return (int) (Math.round(getAverageTestSize() * totalUnimplementedTests())); }
private long countRequirementsWithoutTestsIn(Requirement rootRequirement) { return getFlattenedRequirements(rootRequirement).stream() .filter( requirement -> testOutcomes.forRequirement(requirement).getTotal() == 0) .count(); }
/** * @return The overall result for the tests in this test outcome set. */ public TestResult getResult() { return TestResultList.overallResultFrom(getCurrentTestResults()); }
private boolean aMatchingTestExists(TestResult expectedResult, TestType testType) { return (countTestsWithResult(expectedResult, testType) > 0); }
public boolean testsRequirement(Requirement requirement) { return requirement.equals(getRequirement()) || testOutcomes.containsTag(requirement.asTag()); }
private Element buildTestSuiteElement(Document doc, String testCaseName, TestOutcomes testCaseOutcomes) { int errors = testCaseOutcomes.count(TestType.ANY).withResult(TestResult.ERROR); int failures = testCaseOutcomes.count(TestType.ANY).withResult(TestResult.FAILURE); int success = testCaseOutcomes.count(TestType.ANY).withResult(TestResult.SUCCESS); int skipped = testCaseOutcomes.getTotal() - errors - failures - success; Element testSuiteElement = doc.createElement("testsuite"); testSuiteElement.setAttribute("name", testCaseName); testSuiteElement.setAttribute("time", Double.toString(testCaseOutcomes.getDurationInSeconds())); testSuiteElement.setAttribute("tests", Integer.toString(testCaseOutcomes.getTestCount())); testSuiteElement.setAttribute("errors", Integer.toString(errors)); testSuiteElement.setAttribute("skipped", Integer.toString(skipped)); testSuiteElement.setAttribute("failures", Integer.toString(failures)); if (testCaseOutcomes.getStartTime() != null) { testSuiteElement.setAttribute("timestamp", testCaseOutcomes.getStartTime().toString("YYYY-MM-DD hh:mm:ss")); } return testSuiteElement; } }
public Double withResult(TestResult testResult) { int matchingTestCount = countTestsWithResult(testResult, testType); return (getTotal() == 0) ? 0 : (matchingTestCount / (double) getTotal()); }
private List<Release> extractReleasesFromTestOutcomeAnnotations(TestOutcomes testOutcomes) { List<Release> releases = Lists.newArrayList(); List<TestTag> releaseTags = testOutcomes.findMatchingTags() .withType("version") .withNameIn(matchingNames(releaseTypes.get(0))) .list(); for (TestTag tag : releaseTags) { releases.add(extractReleaseFor(tag, testOutcomes.withTag(tag), 1, NO_PARENTS)); } return releases; }
private void buildRequirements(List<RequirementOutcome> outcomes, List<RequirementsTagProvider> requirementsTagProviders, Requirement requirement) { TestOutcomes outcomesForRequirement = testOutcomes.forRequirement(requirement); int requirementsWithoutTests = countRequirementsWithoutTestsIn(requirement); int estimatedUnimplementedTests = requirementsWithoutTests * estimatedTestsPerRequirement(); outcomes.add(new RequirementOutcome(requirement, outcomesForRequirement, requirementsWithoutTests, estimatedUnimplementedTests, issueTracking)); }
@Override public int countSubrequirementsWithNoTests() { int totalSubrequirmentsWithNoTests = 0; for (Requirement req : requirement.getChildren()) { if (testOutcomes.forRequirement(req).getOutcomes().isEmpty()) { totalSubrequirmentsWithNoTests++; } } return totalSubrequirmentsWithNoTests; }