Skip to content

Commit

Permalink
[Core] Remove UnreportedStepExecutor (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpkorstanje authored May 18, 2018
1 parent 158a4f7 commit 4d09d8c
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 69 deletions.
36 changes: 1 addition & 35 deletions core/src/main/java/cucumber/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,15 @@
import cucumber.runtime.RuntimeOptions;
import cucumber.runtime.PickleStepDefinitionMatch;
import cucumber.runtime.UndefinedPickleStepDefinitionMatch;
import cucumber.runtime.UnreportedStepExecutor;
import gherkin.events.PickleEvent;
import gherkin.pickles.Argument;
import gherkin.pickles.PickleLocation;
import gherkin.pickles.PickleRow;
import gherkin.pickles.PickleStep;
import gherkin.pickles.PickleString;
import gherkin.pickles.PickleTable;
import gherkin.pickles.PickleTag;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class Runner implements UnreportedStepExecutor {
public class Runner {
private final Glue glue;
private final EventBus bus;
private final Collection<? extends Backend> backends;
Expand All @@ -41,37 +34,10 @@ public Runner(Glue glue, EventBus bus, Collection<? extends Backend> backends, R
this.backends = backends;
for (Backend backend : backends) {
backend.loadGlue(glue, runtimeOptions.getGlue());
backend.setUnreportedStepExecutor(this);
}

}

//TODO: Maybe this should go into the cucumber step execution model and it should return the result of that execution!
@Override
public void runUnreportedStep(String featurePath, String language, String stepName, int line, List<PickleRow> dataTableRows, PickleString docString) throws Throwable {
List<Argument> arguments = new ArrayList<Argument>();
if (dataTableRows != null && !dataTableRows.isEmpty()) {
arguments.add(new PickleTable(dataTableRows));
} else if (docString != null) {
arguments.add(docString);
}
PickleStep step = new PickleStep(stepName, arguments, Collections.<PickleLocation>emptyList());

PickleStepDefinitionMatch match = glue.stepDefinitionMatch(featurePath, step);
if (match == null) {
UndefinedStepException error = new UndefinedStepException(step);

StackTraceElement[] originalTrace = error.getStackTrace();
StackTraceElement[] newTrace = new StackTraceElement[originalTrace.length + 1];
newTrace[0] = new StackTraceElement("✽", "StepDefinition", featurePath, line);
System.arraycopy(originalTrace, 0, newTrace, 1, originalTrace.length);
error.setStackTrace(newTrace);

throw error;
}
match.runStep(language, null);
}

public void runPickle(PickleEvent pickle) {
buildBackendWorlds(); // Java8 step definitions will be added to the glue here
TestCase testCase = createTestCaseForPickle(pickle);
Expand Down
6 changes: 0 additions & 6 deletions core/src/main/java/cucumber/runtime/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ public interface Backend {
*/
void loadGlue(Glue glue, List<String> gluePaths);

/**
* Invoked once, handing the backend a reference to a step executor
* in case the backend needs to call steps defined within other steps
*/
void setUnreportedStepExecutor(UnreportedStepExecutor executor);

/**
* Invoked before a new scenario starts. Implementations should do any necessary
* setup of new, isolated state here.
Expand Down
11 changes: 0 additions & 11 deletions core/src/main/java/cucumber/runtime/UnreportedStepExecutor.java

This file was deleted.

7 changes: 0 additions & 7 deletions java/src/main/java/cucumber/runtime/java/JavaBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
import cucumber.runtime.Backend;
import cucumber.runtime.ClassFinder;
import cucumber.runtime.CucumberException;
import cucumber.runtime.DuplicateStepDefinitionException;
import cucumber.runtime.Env;
import cucumber.runtime.Glue;
import cucumber.runtime.HookDefinition;
import cucumber.runtime.StepDefinition;
import cucumber.runtime.UnreportedStepExecutor;
import cucumber.runtime.Utils;
import cucumber.runtime.io.ResourceLoader;
import cucumber.runtime.io.ResourceLoaderClassFinder;
Expand Down Expand Up @@ -111,11 +109,6 @@ public void loadGlue(Glue glue, Method method, Class<?> glueCodeClass) {
methodScanner.scan(this, method, glueCodeClass);
}

@Override
public void setUnreportedStepExecutor(UnreportedStepExecutor executor) {
//Not used here yet
}

@Override
public void buildWorld() {
objectFactory.start();
Expand Down
5 changes: 0 additions & 5 deletions junit/src/test/java/cucumber/runtime/stub/StubBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.cucumber.stepexpression.TypeRegistry;
import cucumber.runtime.Backend;
import cucumber.runtime.Glue;
import cucumber.runtime.UnreportedStepExecutor;
import cucumber.runtime.io.ResourceLoader;
import cucumber.runtime.snippets.FunctionNameGenerator;
import gherkin.pickles.PickleStep;
Expand All @@ -23,10 +22,6 @@ public StubBackend(ResourceLoader resourceLoader, TypeRegistry typeRegistry) {
public void loadGlue(Glue glue, List<String> gluePaths) {
}

@Override
public void setUnreportedStepExecutor(UnreportedStepExecutor executor) {
}

@Override
public void buildWorld() {
}
Expand Down
5 changes: 0 additions & 5 deletions testng/src/test/java/cucumber/runtime/stub/StubBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.cucumber.stepexpression.TypeRegistry;
import cucumber.runtime.Backend;
import cucumber.runtime.Glue;
import cucumber.runtime.UnreportedStepExecutor;
import cucumber.runtime.io.ResourceLoader;
import cucumber.runtime.snippets.FunctionNameGenerator;
import gherkin.pickles.PickleStep;
Expand All @@ -23,10 +22,6 @@ public StubBackend(ResourceLoader resourceLoader, TypeRegistry typeRegistry) {
public void loadGlue(Glue glue, List<String> gluePaths) {
}

@Override
public void setUnreportedStepExecutor(UnreportedStepExecutor executor) {
}

@Override
public void buildWorld() {
}
Expand Down

0 comments on commit 4d09d8c

Please sign in to comment.