How to use addDuration method of net.serenitybdd.cucumber.suiteslicing.TestScenarioResults class

Best Serenity Cucumber code snippet using net.serenitybdd.cucumber.suiteslicing.TestScenarioResults.addDuration Github


Full Screen

...60    private void addStatistics(TestStatistics statistics) {61        statistics.records().forEach(record -> {62            Optional<TestScenarioResults> existingResult = -> existing.scenarioKey.equals(record.scenarioKey)).findFirst();63            if (existingResult.isPresent()) {64                existingResult.get().addDuration(record.duration);65            } else {66                results.add(TestScenarioResults.create(record));67            }68        });69    }70    private BigDecimal averageDuration() {71        return records().stream().map(TestScenarioResult::duration).collect(BigDecimalAverageCollector.create());72    }73    private BigDecimal average(String feature, String scenario) {74        LOGGER.warn("Returning average weighting of {} due to non-match of {} -> {}", averageDuration(), feature, scenario);75        return averageDuration();76    }77    public String toString() {78        return  Inflector.getInstance().kebabCase(this.getClass().getSimpleName());...

Full Screen

Full Screen Github


Full Screen

...13    private final String scenario;14    public static TestScenarioResults create(TestScenarioResult testScenarioDuration) {15        return new TestScenarioResults(testScenarioDuration);16    }17    public void addDuration(BigDecimal duration) {18        durations.add(duration);19    }20    private TestScenarioResults(TestScenarioResult testScenarioResult) {21        this.durations = newArrayList(testScenarioResult.duration);22        this.scenarioKey = testScenarioResult.scenarioKey;23        this.feature = testScenarioResult.feature;24        this.scenario = testScenarioResult.scenario;25    }26    public TestScenarioResult average() {27        return new TestScenarioResult(feature, scenario,;28    }29    @Override30    public boolean equals(Object o) {31        return reflectionEquals(this, o);...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Serenity Cucumber automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in TestScenarioResults

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?