use of cucumber.runtime.StepDefinitionMatch in project cucumber-jvm by cucumber.
the class UsageFormatterTest method resultWithNullDuration.
@Test
public void resultWithNullDuration() {
Appendable out = mock(Appendable.class);
UsageFormatter usageFormatter = new UsageFormatter(out);
StepDefinitionMatch match = mockStepDefinitionMatch();
usageFormatter.match(match);
Result result = mock(Result.class);
when(result.getDuration()).thenReturn(null);
when(result.getStatus()).thenReturn(Result.PASSED);
usageFormatter.result(result);
Map<String, List<UsageFormatter.StepContainer>> usageMap = usageFormatter.usageMap;
assertEquals(usageMap.size(), 1);
List<UsageFormatter.StepContainer> durationEntries = usageMap.get("stepDef");
assertEquals(durationEntries.size(), 1);
assertEquals(durationEntries.get(0).name, "step");
assertEquals(durationEntries.get(0).durations.size(), 1);
assertEquals(durationEntries.get(0).durations.get(0).duration, BigDecimal.ZERO);
}
use of cucumber.runtime.StepDefinitionMatch in project cucumber-jvm by cucumber.
the class UsageFormatterTest method resultWithStep.
@Test
public void resultWithStep() {
Appendable out = mock(Appendable.class);
UsageFormatter usageFormatter = new UsageFormatter(out);
StepDefinitionMatch match = mockStepDefinitionMatch();
usageFormatter.match(match);
Result result = mock(Result.class);
when(result.getDuration()).thenReturn(12345L);
when(result.getStatus()).thenReturn(Result.PASSED);
usageFormatter.result(result);
Map<String, List<UsageFormatter.StepContainer>> usageMap = usageFormatter.usageMap;
assertEquals(usageMap.size(), 1);
List<UsageFormatter.StepContainer> durationEntries = usageMap.get("stepDef");
assertEquals(durationEntries.size(), 1);
assertEquals(durationEntries.get(0).name, "step");
assertEquals(durationEntries.get(0).durations.size(), 1);
assertEquals(durationEntries.get(0).durations.get(0).duration, BigDecimal.valueOf(12345));
}
use of cucumber.runtime.StepDefinitionMatch in project cucumber-jvm by cucumber.
the class FromDataTableTest method runStepDef.
private StepDefs runStepDef(Method method, List<DataTableRow> rows) throws Throwable {
StepDefs stepDefs = new StepDefs();
StepDefinition stepDefinition = new StubStepDefinition(stepDefs, method, "some pattern");
Step stepWithRows = new Step(NO_COMMENTS, "Given ", "something", 10, rows, null);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
StepDefinitionMatch stepDefinitionMatch = new StepDefinitionMatch(NO_ARGS, stepDefinition, "some.feature", stepWithRows, new LocalizedXStreams(classLoader));
stepDefinitionMatch.runStep(new I18n("en"));
return stepDefs;
}
use of cucumber.runtime.StepDefinitionMatch in project cucumber-jvm by cucumber.
the class UsageFormatterTest method resultWithZeroDuration.
@Test
public void resultWithZeroDuration() {
Appendable out = mock(Appendable.class);
UsageFormatter usageFormatter = new UsageFormatter(out);
StepDefinitionMatch match = mockStepDefinitionMatch();
usageFormatter.match(match);
Result result = mock(Result.class);
when(result.getDuration()).thenReturn(0L);
when(result.getStatus()).thenReturn(Result.PASSED);
usageFormatter.result(result);
Map<String, List<UsageFormatter.StepContainer>> usageMap = usageFormatter.usageMap;
assertEquals(usageMap.size(), 1);
List<UsageFormatter.StepContainer> durationEntries = usageMap.get("stepDef");
assertEquals(durationEntries.size(), 1);
assertEquals(durationEntries.get(0).name, "step");
assertEquals(durationEntries.get(0).durations.size(), 1);
assertEquals(durationEntries.get(0).durations.get(0).duration, BigDecimal.ZERO);
}
use of cucumber.runtime.StepDefinitionMatch in project cucumber-jvm by cucumber.
the class UsageFormatterTest method mockStepDefinitionMatch.
private StepDefinitionMatch mockStepDefinitionMatch() {
StepDefinitionMatch match = mock(StepDefinitionMatch.class, Mockito.RETURNS_MOCKS);
when(match.getPattern()).thenReturn("stepDef");
when(match.getStepLocation()).thenReturn(new StackTraceElement("x", "y", "z", 3));
when(match.getStepName()).thenReturn("step");
return match;
}
Aggregations