Skip to content

Commit

Permalink
Support for setting execution order in SpecInfo
Browse files Browse the repository at this point in the history
Can be used by extensions.

Relates to spockframework#1443.
  • Loading branch information
kriegaex committed Apr 13, 2023
1 parent e97e2ed commit 0d2d0bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ include::include.adoc[]

== 2.4 (tbd)

* Support for setting execution order (a.k.a. run order) in `SpecInfo`, can be used by extensions

== 2.4-M1 (2022-11-30)

* Fix issues with Spring 6/Spring Boot 3 spockPull:1541[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import org.junit.platform.engine.*;

import static java.util.Comparator.comparingInt;

class SpockEngineDiscoveryPostProcessor {

private static final Object[] EMPTY_ARGS = new Object[0];
Expand All @@ -14,6 +16,7 @@ SpockEngineDescriptor postProcessEngineDescriptor(UniqueId uniqueId, RunContext
SpockEngineDescriptor processedEngineDescriptor = new SpockEngineDescriptor(uniqueId, runContext);
engineDescriptor.getChildren().stream()
.map(child -> processSpecNode(child, runContext))
.sorted(comparingInt(child -> child instanceof SpecNode ? ((SpecNode) child).getNodeInfo().getExecutionOrder() : 0))
.forEach(processedEngineDescriptor::addChild);
return processedEngineDescriptor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class SpecInfo extends SpecElementInfo<NodeInfo, Class<?>> implements IMe
private ExecutionMode executionMode = null;
private ExecutionMode childExecutionMode = null;

private int executionOrder;

private String pkg;
private String filename;
private String narrative;
Expand All @@ -66,6 +68,14 @@ public class SpecInfo extends SpecElementInfo<NodeInfo, Class<?>> implements IMe

private final List<FeatureInfo> features = new ArrayList<>();

public int getExecutionOrder() {
return executionOrder;
}

public void setExecutionOrder(int executionOrder) {
this.executionOrder = executionOrder;
}

public String getPackage() {
return pkg;
}
Expand Down

0 comments on commit 0d2d0bb

Please sign in to comment.