Skip to content

Commit ebd2a3e

Browse files
committed
Introduce SpecProcessor interface and SpecOrderer, implementing it
SpecProcessor is designed to generically process a Collection<SpecInfo>, which e.g. is available to global extensions using the recently introduced lifecycle method initSpecs(Collection<SpecInfo>). New abstract class SpecOrderer is meant to be extended by other orderers wishing to assign run orders to specs/features via - SpecInfo.setExecutionOrder, - FeatureInfo.setExecutionOrder. Relates to #1443.
1 parent e800ba9 commit ebd2a3e

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.spockframework.runtime;
2+
3+
import org.spockframework.runtime.model.SpecInfo;
4+
5+
import java.util.Collection;
6+
7+
public interface SpecProcessor {
8+
void process(Collection<SpecInfo> specs);
9+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.spockframework.runtime.extension.builtin.orderer;
2+
3+
import org.spockframework.runtime.SpecProcessor;
4+
import org.spockframework.runtime.model.SpecInfo;
5+
6+
import java.util.Collection;
7+
8+
public abstract class SpecOrderer implements SpecProcessor {
9+
protected final boolean orderSpecs;
10+
protected final boolean orderFeatures;
11+
12+
public SpecOrderer(boolean orderSpecs, boolean orderFeatures) {
13+
this.orderSpecs = orderSpecs;
14+
this.orderFeatures = orderFeatures;
15+
}
16+
17+
@Override
18+
public void process(Collection<SpecInfo> specs) {
19+
if (orderSpecs)
20+
orderSpecs(specs);
21+
if (orderFeatures)
22+
orderFeatures(specs);
23+
}
24+
25+
protected abstract void orderSpecs(Collection<SpecInfo> specs);
26+
protected abstract void orderFeatures(Collection<SpecInfo> specs);
27+
28+
public boolean isOrderSpecs() {
29+
return orderSpecs;
30+
}
31+
32+
public boolean isOrderFeatures() {
33+
return orderFeatures;
34+
}
35+
}

0 commit comments

Comments
 (0)