-
Notifications
You must be signed in to change notification settings - Fork 405
Expand file tree
/
Copy pathStepsOverviewPageTest.java
More file actions
66 lines (52 loc) · 2.08 KB
/
StepsOverviewPageTest.java
File metadata and controls
66 lines (52 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package net.masterthought.cucumber.generators;
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.velocity.VelocityContext;
import org.junit.Before;
import org.junit.Test;
import net.masterthought.cucumber.generators.integrations.PageTest;
import net.masterthought.cucumber.json.support.StepObject;
import net.masterthought.cucumber.util.Util;
/**
* @author Damian Szczepanik (damianszczepanik@github)
*/
public class StepsOverviewPageTest extends PageTest {
@Before
public void setUp() {
setUpWithJson(SAMPLE_JSON);
}
@Test
public void getWebPage_ReturnsStepsOverviewFileName() {
// given
page = new StepsOverviewPage(reportResult, configuration);
// when
String fileName = page.getWebPage();
// then
assertThat(fileName).isEqualTo(StepsOverviewPage.WEB_PAGE);
}
@Test
public void prepareReport_AddsCustomProperties() {
// given
page = new StepsOverviewPage(reportResult, configuration);
// when
page.prepareReport();
// then
VelocityContext context = page.context;
assertThat(context.getKeys()).hasSize(16);
assertThat(context.get("all_steps")).isEqualTo(steps);
int allOccurrences = 0;
long allDurations = 0;
long maxDuration = 0;
for (StepObject stepObject : reportResult.getAllSteps()) {
allOccurrences += stepObject.getTotalOccurrences();
allDurations += stepObject.getDuration();
if (stepObject.getDuration() > maxDuration) {
maxDuration = stepObject.getMaxDuration();
}
}
assertThat(context.get("all_occurrences")).isEqualTo(allOccurrences);
long average = allDurations / (allOccurrences == 0 ? 1 : allOccurrences);
assertThat(context.get("all_average_duration")).isEqualTo(Util.formatDuration(average));
assertThat(context.get("all_max_duration")).isEqualTo(Util.formatDuration(maxDuration));
assertThat(context.get("all_durations")).isEqualTo(Util.formatDuration(allDurations));
}
}