Skip to content
Closed
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 @@ -27,6 +27,11 @@ public class AllureStorage {
public LinkedList<String> initialValue() {
return new LinkedList<>();
}

@Override
protected LinkedList<String> childValue(final LinkedList<String> parentStepContext) {
return new LinkedList<>(parentStepContext);
}
};

@SuppressWarnings("PMD.NullAssignment")
Expand Down
44 changes: 44 additions & 0 deletions allure-java-commons/src/test/java/io/qameta/allure/StepsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.Test;

import java.util.UUID;
import java.util.stream.Collectors;

import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -71,6 +72,35 @@ public void shouldSupportArrayParameters() throws Exception {
);
}

@Test
public void shouldSupportParallelStepsRun() {
final AllureResultsWriterStub results = runStep(() -> {
Thread[] threads = {
new Thread(this::outerStep),
new Thread(this::outerStep),
new Thread(this::outerStep)
};
for (Thread thread : threads) {
thread.start();
}
try {
for (Thread thread : threads) {
thread.join();
}
} catch (InterruptedException ignored) { }
});

assertThat(results.getTestResults())
.flatExtracting(TestResult::getSteps)
.extracting(
ExecutableItem::getName,
step -> step.getSteps().stream().map(StepResult::getName).collect(Collectors.toList())
)
.containsOnly(
tuple("outerStep", asList("innerStep", "innerStep", "innerStep"))
);
}

@Step("\"{user.emails.address}\", \"{user.emails}\", \"{user.emails.attachments}\", \"{user.password}\", \"{}\"," +
" \"{user.card.number}\", \"{missing}\", {staySignedIn}")
private void loginWith(final DummyUser user, final boolean staySignedIn) {
Expand All @@ -84,6 +114,20 @@ public void checkData(final String value) {
public void step(final String... parameters) {
}

@Step
private void outerStep() {
for (int i = 0; i < 3; i++) {
innerStep();
}
}

@Step
private void innerStep() {
try {
Thread.sleep(100);
} catch (InterruptedException ignored) { }
}

public static AllureResultsWriterStub runStep(final Runnable runnable) {
final AllureResultsWriterStub results = new AllureResultsWriterStub();
final AllureLifecycle lifecycle = new AllureLifecycle(results);
Expand Down