Skip to content

Commit

Permalink
Introduce SpecProcessor interface and SpecOrderer, implementing it
Browse files Browse the repository at this point in the history
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
kriegaex committed Apr 16, 2023
1 parent 2d64e6b commit 48d05e8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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);
}
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;
}
}

0 comments on commit 48d05e8

Please sign in to comment.