public List<TestOutcome> aggregateTestOutcomesByTestMethods() { List<TestOutcome> allOutcomes = getTestOutcomesForAllParameterSets(); if (allOutcomes.isEmpty()) { return Lists.newArrayList(); } else { return aggregatedScenarioOutcomes(allOutcomes); } }
public List<TestOutcome> getTestOutcomesForAllParameterSets() { List<TestOutcome> testOutcomes = new ArrayList<>(); for (Runner runner : serenityParameterizedRunner.getRunners()) { for (TestOutcome testOutcome : ((SerenityRunner) runner).getTestOutcomes()) { if (!testOutcomes.contains(testOutcome)) { testOutcomes.add(testOutcome); } } } return testOutcomes; }
private List<TestOutcome> aggregatedScenarioOutcomes(List<TestOutcome> allOutcomes) { Map<String, TestOutcome> scenarioOutcomes = new HashMap<>(); for (TestOutcome testOutcome : allOutcomes) { final String normalizedMethodName = baseMethodName(testOutcome); TestOutcome scenarioOutcome = scenarioOutcomeFor(normalizedMethodName, testOutcome, scenarioOutcomes); recordTestOutcomeAsSteps(testOutcome, scenarioOutcome); if (testOutcome.isDataDriven()) { updateResultsForAnyExternalFailures( testOutcome, scenarioOutcomes.get(normalizedMethodName)); scenarioOutcome.addDataFrom(testOutcome.getDataTable()); } } List<TestOutcome> aggregatedScenarioOutcomes = new ArrayList<>(); aggregatedScenarioOutcomes.addAll(scenarioOutcomes.values()); return aggregatedScenarioOutcomes; }
private void recordTestOutcomeAsSteps(TestOutcome testOutcome, TestOutcome scenarioOutcome) { final String name = alternativeMethodName(testOutcome); TestStep nestedStep = TestStep.forStepCalled(name).withResult(testOutcome.getResult()); List<TestStep> testSteps = testOutcome.getTestSteps(); if (testOutcome.getTestFailureCause() != null) { nestedStep.failedWith(testOutcome.getTestFailureCause().toException()); } if (!testSteps.isEmpty()) { for (TestStep nextStep : testSteps) { nextStep.setDescription( normalizeTestStepDescription( nextStep.getDescription(), scenarioOutcome.getTestSteps().size() + 1)); nestedStep.addChildStep(nextStep); nestedStep.setDuration(nextStep.getDuration() + nestedStep.getDuration()); } } if (nestedStep.getDuration() == 0) { nestedStep.setDuration(testOutcome.getDuration()); } scenarioOutcome.recordStep(nestedStep); }