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

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

Run Serenity Cucumber automation tests on LambdaTest cloud grid

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

copy
1package net.serenitybdd.cucumber.suiteslicing;
2
3import net.serenitybdd.cucumber.util.BigDecimalAverageCollector;
4
5import java.math.BigDecimal;
6import java.util.List;
7
8import static com.google.common.collect.Lists.newArrayList;
9import static org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals;
10import static org.apache.commons.lang3.builder.HashCodeBuilder.reflectionHashCode;
11import static org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString;
12
13public class TestScenarioResults {
14
15    public final String scenarioKey;
16    public final List<BigDecimal> durations;
17    private final String feature;
18    private final String scenario;
19
20    public static TestScenarioResults create(TestScenarioResult testScenarioDuration) {
21        return new TestScenarioResults(testScenarioDuration);
22    }
23
24    public void addDuration(BigDecimal duration) {
25        durations.add(duration);
26    }
27
28    private TestScenarioResults(TestScenarioResult testScenarioResult) {
29        this.durations = newArrayList(testScenarioResult.duration);
30        this.scenarioKey = testScenarioResult.scenarioKey;
31        this.feature = testScenarioResult.feature;
32        this.scenario = testScenarioResult.scenario;
33    }
34
35    public TestScenarioResult average() {
36        return new TestScenarioResult(feature, scenario, durations.stream().collect(BigDecimalAverageCollector.create()));
37    }
38
39    @Override
40    public boolean equals(Object o) {
41        return reflectionEquals(this, o);
42    }
43
44    @Override
45    public int hashCode() {
46        return reflectionHashCode(this);
47    }
48
49    @Override
50    public String toString() {
51        return reflectionToString(this);
52    }
53}
54
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in TestScenarioResults

Trigger average code on LambdaTest Cloud Grid

Execute automation tests with average on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)