forked from spockframework/spock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 spockframework#1443.
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
spock-core/src/main/java/org/spockframework/runtime/SpecProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.spockframework.runtime; | ||
|
||
import org.spockframework.runtime.model.SpecInfo; | ||
|
||
import java.util.Collection; | ||
|
||
public interface SpecProcessor { | ||
void process(Collection<SpecInfo> specs); | ||
} |
35 changes: 35 additions & 0 deletions
35
...-core/src/main/java/org/spockframework/runtime/extension/builtin/orderer/SpecOrderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.spockframework.runtime.extension.builtin.orderer; | ||
|
||
import org.spockframework.runtime.SpecProcessor; | ||
import org.spockframework.runtime.model.SpecInfo; | ||
|
||
import java.util.Collection; | ||
|
||
public abstract class SpecOrderer implements SpecProcessor { | ||
protected final boolean orderSpecs; | ||
protected final boolean orderFeatures; | ||
|
||
public SpecOrderer(boolean orderSpecs, boolean orderFeatures) { | ||
this.orderSpecs = orderSpecs; | ||
this.orderFeatures = orderFeatures; | ||
} | ||
|
||
@Override | ||
public void process(Collection<SpecInfo> specs) { | ||
if (orderSpecs) | ||
orderSpecs(specs); | ||
if (orderFeatures) | ||
orderFeatures(specs); | ||
} | ||
|
||
protected abstract void orderSpecs(Collection<SpecInfo> specs); | ||
protected abstract void orderFeatures(Collection<SpecInfo> specs); | ||
|
||
public boolean isOrderSpecs() { | ||
return orderSpecs; | ||
} | ||
|
||
public boolean isOrderFeatures() { | ||
return orderFeatures; | ||
} | ||
} |