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
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.io.ByteArrayInputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
Expand Down Expand Up @@ -100,6 +101,7 @@ public class AllureCucumber5Jvm implements ConcurrentEventListener {

private static final String TXT_EXTENSION = ".txt";
private static final String TEXT_PLAIN = "text/plain";
private static final String CUCUMBER_WORKING_DIR = Paths.get("").toUri().toString();

@SuppressWarnings("unused")
public AllureCucumber5Jvm() {
Expand Down Expand Up @@ -276,12 +278,18 @@ private String getHookStepUuid(final HookTestStep step) {
}

private String getHistoryId(final TestCase testCase) {
final String testCaseLocation = testCase.getUri().toString()
.substring(testCase.getUri().toString().lastIndexOf('/') + 1)
+ ":" + testCase.getLine();
final String testCaseLocation = getTestCaseUri(testCase) + ":" + testCase.getLine();
return md5(testCaseLocation);
}

private String getTestCaseUri(final TestCase testCase) {
final String testCaseUri = testCase.getUri().toString();
if (testCaseUri.startsWith(CUCUMBER_WORKING_DIR)) {
return testCaseUri.substring(CUCUMBER_WORKING_DIR.length());
}
return testCaseUri;
}

private Status translateTestCaseStatus(final Result testCaseResult) {
switch (testCaseResult.getStatus()) {
case FAILED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void shouldPersistHistoryIdForScenarios() {

final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults.get(0).getHistoryId())
.isEqualTo("8eea9ed4458a49d418859d1398580671");
.isEqualTo("892e5eabe51184301cf1358453c9f052");
}

@AllureFeatures.History
Expand All @@ -577,11 +577,20 @@ void shouldPersistHistoryIdForExamples() {
final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults)
.extracting(TestResult::getHistoryId)
.containsExactlyInAnyOrder("42a7821e775ec18b112f92e96f0510a5", "afb27d131ed8d41b3f867895a26d2590");
.containsExactlyInAnyOrder("c0f824814a130048e9f86358363cf23e", "646aca5d0775cd4f13161e1ea1a68c39");
}

private Comparator<TestResult> byHistoryId =
Comparator.comparing(TestResult::getHistoryId);
@AllureFeatures.History
@Test
void shouldPersistDifferentHistoryIdComparedToTheSameTestCaseInDifferentLocation() {
final AllureResultsWriterStub writer = new AllureResultsWriterStub();
runFeature(writer, "features/simple.feature");
runFeature(writer, "features/same/simple.feature");

final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults.get(0).getHistoryId())
.isNotEqualTo(testResults.get(1).getHistoryId());
}

@AllureFeatures.Parallel
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Simple feature

Scenario: Add a to b
Given a is 5
And b is 10
When I add a to b
Then result is 15
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.io.ByteArrayInputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
Expand Down Expand Up @@ -99,6 +100,7 @@ public class AllureCucumber6Jvm implements ConcurrentEventListener {

private static final String TXT_EXTENSION = ".txt";
private static final String TEXT_PLAIN = "text/plain";
private static final String CUCUMBER_WORKING_DIR = Paths.get("").toUri().toString();

@SuppressWarnings("unused")
public AllureCucumber6Jvm() {
Expand Down Expand Up @@ -279,12 +281,18 @@ private String getHookStepUuid(final HookTestStep step) {
}

private String getHistoryId(final TestCase testCase) {
final String testCaseLocation = testCase.getUri().toString()
.substring(testCase.getUri().toString().lastIndexOf('/') + 1)
+ ":" + testCase.getLocation().getLine();
final String testCaseLocation = getTestCaseUri(testCase) + ":" + testCase.getLocation().getLine();
return md5(testCaseLocation);
}

private String getTestCaseUri(final TestCase testCase) {
final String testCaseUri = testCase.getUri().toString();
if (testCaseUri.startsWith(CUCUMBER_WORKING_DIR)) {
return testCaseUri.substring(CUCUMBER_WORKING_DIR.length());
}
return testCaseUri;
}

private Status translateTestCaseStatus(final Result testCaseResult) {
switch (testCaseResult.getStatus()) {
case FAILED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void shouldPersistHistoryIdForScenarios() {

final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults.get(0).getHistoryId())
.isEqualTo("8eea9ed4458a49d418859d1398580671");
.isEqualTo("892e5eabe51184301cf1358453c9f052");
}

@AllureFeatures.History
Expand All @@ -577,11 +577,20 @@ void shouldPersistHistoryIdForExamples() {
final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults)
.extracting(TestResult::getHistoryId)
.containsExactlyInAnyOrder("42a7821e775ec18b112f92e96f0510a5", "afb27d131ed8d41b3f867895a26d2590");
.containsExactlyInAnyOrder("c0f824814a130048e9f86358363cf23e", "646aca5d0775cd4f13161e1ea1a68c39");
}

private Comparator<TestResult> byHistoryId =
Comparator.comparing(TestResult::getHistoryId);
@AllureFeatures.History
@Test
void shouldPersistDifferentHistoryIdComparedToTheSameTestCaseInDifferentLocation() {
final AllureResultsWriterStub writer = new AllureResultsWriterStub();
runFeature(writer, "features/simple.feature");
runFeature(writer, "features/same/simple.feature");

final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults.get(0).getHistoryId())
.isNotEqualTo(testResults.get(1).getHistoryId());
}

@AllureFeatures.Parallel
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Simple feature

Scenario: Add a to b
Given a is 5
And b is 10
When I add a to b
Then result is 15
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.io.ByteArrayInputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
Expand Down Expand Up @@ -99,6 +100,7 @@ public class AllureCucumber7Jvm implements ConcurrentEventListener {

private static final String TXT_EXTENSION = ".txt";
private static final String TEXT_PLAIN = "text/plain";
private static final String CUCUMBER_WORKING_DIR = Paths.get("").toUri().toString();

@SuppressWarnings("unused")
public AllureCucumber7Jvm() {
Expand Down Expand Up @@ -279,12 +281,18 @@ private String getHookStepUuid(final HookTestStep step) {
}

private String getHistoryId(final TestCase testCase) {
final String testCaseLocation = testCase.getUri().toString()
.substring(testCase.getUri().toString().lastIndexOf('/') + 1)
+ ":" + testCase.getLocation().getLine();
final String testCaseLocation = getTestCaseUri(testCase) + ":" + testCase.getLocation().getLine();
return md5(testCaseLocation);
}

private String getTestCaseUri(final TestCase testCase) {
final String testCaseUri = testCase.getUri().toString();
if (testCaseUri.startsWith(CUCUMBER_WORKING_DIR)) {
return testCaseUri.substring(CUCUMBER_WORKING_DIR.length());
}
return testCaseUri;
}

private Status translateTestCaseStatus(final Result testCaseResult) {
switch (testCaseResult.getStatus()) {
case FAILED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void shouldPersistHistoryIdForScenarios() {

final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults.get(0).getHistoryId())
.isEqualTo("8eea9ed4458a49d418859d1398580671");
.isEqualTo("892e5eabe51184301cf1358453c9f052");
}

@AllureFeatures.History
Expand All @@ -577,11 +577,20 @@ void shouldPersistHistoryIdForExamples() {
final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults)
.extracting(TestResult::getHistoryId)
.containsExactlyInAnyOrder("42a7821e775ec18b112f92e96f0510a5", "afb27d131ed8d41b3f867895a26d2590");
.containsExactlyInAnyOrder("c0f824814a130048e9f86358363cf23e", "646aca5d0775cd4f13161e1ea1a68c39");
}

private Comparator<TestResult> byHistoryId =
Comparator.comparing(TestResult::getHistoryId);
@AllureFeatures.History
@Test
void shouldPersistDifferentHistoryIdComparedToTheSameTestCaseInDifferentLocation() {
final AllureResultsWriterStub writer = new AllureResultsWriterStub();
runFeature(writer, "features/simple.feature");
runFeature(writer, "features/same/simple.feature");

final List<TestResult> testResults = writer.getTestResults();
assertThat(testResults.get(0).getHistoryId())
.isNotEqualTo(testResults.get(1).getHistoryId());
}

@AllureFeatures.Parallel
@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Simple feature

Scenario: Add a to b
Given a is 5
And b is 10
When I add a to b
Then result is 15