Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion allure-cucumber2-jvm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ configurations {
agent
}

def cucumber_version = '2.1.0'
def cucumber_version = '2.3.1'

dependencies {
agent 'org.aspectj:aspectjweaver'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.HashMap;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -151,8 +152,7 @@ private void handleTestStepStarted(final TestStepStarted event) {
cucumberSourceUtils.getKeywordFromSource(currentFeatureFile, event.testStep.getStepLine())
).orElse("UNDEFINED");

final StepResult stepResult = new StepResult();
stepResult
final StepResult stepResult = new StepResult()
.withName(String.format("%s %s", stepKeyword, event.testStep.getPickleStep().getText()))
.withStart(System.currentTimeMillis());

Expand All @@ -162,6 +162,12 @@ private void handleTestStepStarted(final TestStepStarted event) {
.filter(argument -> argument instanceof PickleTable)
.findFirst()
.ifPresent(table -> createDataTableAttachment((PickleTable) table));
} else if (event.testStep.isHook() && event.testStep instanceof UnskipableStep) {
final StepResult stepResult = new StepResult()
.withName(event.testStep.getHookType().toString())
.withStart(System.currentTimeMillis());

lifecycle.startStep(getTestCaseUuid(currentTestCase), getHookStepUuid(event.testStep), stepResult);
}
}

Expand All @@ -186,6 +192,11 @@ private String getStepUuid(final TestStep step) {
+ step.getPickleStep().getText() + step.getStepLine();
}

private String getHookStepUuid(final TestStep step) {
return currentFeature.getName() + getTestCaseUuid(currentTestCase)
+ step.getHookType().toString() + step.getCodeLocation();
}

private String getHistoryId(final TestCase testCase) {
final String testCaseLocation = testCase.getUri() + ":" + testCase.getLine();
return Utils.md5(testCaseLocation);
Expand Down Expand Up @@ -239,16 +250,11 @@ private void createDataTableAttachment(final PickleTable pickleTable) {
}

private void handleHookStep(final TestStepFinished event) {
final String uuid = UUID.randomUUID().toString();
final StepResult stepResult = new StepResult()
.withName(event.testStep.getHookType().toString())
.withStatus(translateTestCaseStatus(event.result))
.withStart(System.currentTimeMillis() - event.result.getDuration())
.withStop(System.currentTimeMillis());

if (!Status.PASSED.equals(stepResult.getStatus())) {
final String uuid = getHookStepUuid(event.testStep);
Consumer<StepResult> stepResult = result -> result.withStatus(translateTestCaseStatus(event.result));

if (!Status.PASSED.equals(translateTestCaseStatus(event.result))) {
final StatusDetails statusDetails = ResultsUtils.getStatusDetails(event.result.getError()).get();
stepResult.withStatusDetails(statusDetails);
if (event.testStep.getHookType() == HookType.Before) {
final TagParser tagParser = new TagParser(currentFeature, currentTestCase);
statusDetails
Expand All @@ -260,9 +266,12 @@ private void handleHookStep(final TestStepFinished event) {
scenarioResult.withStatus(Status.SKIPPED)
.withStatusDetails(statusDetails));
}
stepResult = result -> result
.withStatus(translateTestCaseStatus(event.result))
.withStatusDetails(statusDetails);
}

lifecycle.startStep(getTestCaseUuid(currentTestCase), uuid, stepResult);
lifecycle.updateStep(uuid, stepResult);
lifecycle.stopStep(uuid);
}

Expand Down