use of io.cucumber.plugin.event.TestStep in project cucumber-jvm by cucumber.
the class UnusedStepsSummaryPrinterTest method mockTestStep.
private static TestStep mockTestStep(String location) {
TestStep testStep = mock(TestStep.class);
when(testStep.getCodeLocation()).thenReturn(location);
return testStep;
}
use of io.cucumber.plugin.event.TestStep in project cucumber-jvm by cucumber.
the class UsageFormatterTest method resultWithPassedAndFailedStep.
@Test
void resultWithPassedAndFailedStep() {
OutputStream out = new ByteArrayOutputStream();
UsageFormatter usageFormatter = new UsageFormatter(out);
TestStep testStep = mockTestStep();
Result passed = new Result(Status.PASSED, Duration.ofSeconds(12345L), null);
usageFormatter.handleTestStepFinished(new TestStepFinished(Instant.EPOCH, mock(TestCase.class), testStep, passed));
Result failed = new Result(Status.FAILED, Duration.ZERO, null);
usageFormatter.handleTestStepFinished(new TestStepFinished(Instant.EPOCH, mock(TestCase.class), testStep, failed));
Map<String, List<UsageFormatter.StepContainer>> usageMap = usageFormatter.usageMap;
assertThat(usageMap.size(), is(equalTo(1)));
List<UsageFormatter.StepContainer> durationEntries = usageMap.get("stepDef");
assertThat(durationEntries.size(), is(equalTo(1)));
assertThat(durationEntries.get(0).getName(), is(equalTo("step")));
assertThat(durationEntries.get(0).getDurations().size(), is(equalTo(1)));
assertThat(durationEntries.get(0).getDurations().get(0).getDuration(), is(closeTo(12345.0, EPSILON)));
}
use of io.cucumber.plugin.event.TestStep in project cucumber-jvm by cucumber.
the class UsageFormatterTest method resultWithPassedStep.
@Test
void resultWithPassedStep() {
OutputStream out = new ByteArrayOutputStream();
UsageFormatter usageFormatter = new UsageFormatter(out);
TestStep testStep = mockTestStep();
Result result = new Result(Status.PASSED, Duration.ofMillis(12345L), null);
usageFormatter.handleTestStepFinished(new TestStepFinished(Instant.EPOCH, mock(TestCase.class), testStep, result));
Map<String, List<UsageFormatter.StepContainer>> usageMap = usageFormatter.usageMap;
assertThat(usageMap.size(), is(equalTo(1)));
List<UsageFormatter.StepContainer> durationEntries = usageMap.get("stepDef");
assertThat(durationEntries.size(), is(equalTo(1)));
assertThat(durationEntries.get(0).getName(), is(equalTo("step")));
assertThat(durationEntries.get(0).getDurations().size(), is(equalTo(1)));
assertThat(durationEntries.get(0).getDurations().get(0).getDuration(), is(closeTo(12.345, EPSILON)));
}
use of io.cucumber.plugin.event.TestStep in project cucumber-jvm by cucumber.
the class JUnitReporter method handTestStepStarted.
private void handTestStepStarted(TestStepStarted event) {
TestStep testStep = event.getTestStep();
if (testStep instanceof PickleStepTestStep) {
PickleStepTestStep pickleStep = (PickleStepTestStep) testStep;
if (junitOptions.stepNotifications()) {
Description description = pickleRunner.describeChild(pickleStep.getStep());
stepNotifier = new EachTestNotifier(runNotifier, description);
} else {
stepNotifier = new NoTestNotifier();
}
stepNotifier.fireTestStarted();
}
}
use of io.cucumber.plugin.event.TestStep in project cucumber-jvm by cucumber.
the class JsonFormatter method createTestStep.
private Map<String, Object> createTestStep(PickleStepTestStep testStep) {
Map<String, Object> stepMap = new HashMap<>();
stepMap.put("name", testStep.getStepText());
stepMap.put("line", testStep.getStepLine());
TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testStep.getStepLine());
StepArgument argument = testStep.getStepArgument();
if (argument != null) {
if (argument instanceof DocStringArgument) {
DocStringArgument docStringArgument = (DocStringArgument) argument;
stepMap.put("doc_string", createDocStringMap(docStringArgument));
} else if (argument instanceof DataTableArgument) {
DataTableArgument dataTableArgument = (DataTableArgument) argument;
stepMap.put("rows", createDataTableList(dataTableArgument));
}
}
if (astNode != null) {
Step step = (Step) astNode.node;
stepMap.put("keyword", step.getKeyword());
}
return stepMap;
}
Aggregations