Skip to content

[JUnit] Implement Cucumber as a Junit Platform Engine #1530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 98 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
fa62f6b
Implement proof of concept of JUnit Test Engine for cucumber
mpkorstanje Mar 10, 2018
47fd133
Merge branch 'master' into junit-jupiter
mpkorstanje Nov 30, 2018
a391f43
Run all tests in a package
mpkorstanje Nov 30, 2018
482b6fc
Clean up tests
mpkorstanje Nov 30, 2018
a719a5c
Add logging
mpkorstanje Nov 30, 2018
21cde8e
Add test for FeatureResolver
mpkorstanje Nov 30, 2018
6b242c1
Clean up
mpkorstanje Nov 30, 2018
ea5d454
Clean up
mpkorstanje Nov 30, 2018
34b84f7
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Nov 30, 2018
08f19dd
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Nov 30, 2018
9296268
Map test case results to junit results
mpkorstanje Dec 1, 2018
d6c1ec3
Minor clean up
mpkorstanje Dec 1, 2018
37f3dad
Rename to JUnit Platform Engine
mpkorstanje Dec 1, 2018
ca680d4
Add class path resolver
mpkorstanje Dec 1, 2018
7ca076c
Assert against optional
mpkorstanje Dec 1, 2018
4da66e5
Add uri resolver
mpkorstanje Dec 1, 2018
d56ff43
Add JUnit 5 example
mpkorstanje Dec 2, 2018
401f14a
Add parallel support
mpkorstanje Dec 2, 2018
1a6a793
Merge branch 'extract-dedicated-interfaces-for-options' into junit-ju…
mpkorstanje Dec 2, 2018
92beee0
Add support for selected options
mpkorstanje Dec 2, 2018
31d80f6
Add support for TestTags
mpkorstanje Dec 2, 2018
e9e54eb
Add support for package filtering
mpkorstanje Dec 2, 2018
874a8a9
Refactor things
mpkorstanje Dec 4, 2018
ff11cc3
[Core] Normalize input when parsing
mpkorstanje Dec 6, 2018
a14ff10
Add resolve by UniqueId
mpkorstanje Dec 7, 2018
884eaaa
Polish
mpkorstanje Dec 7, 2018
30b9600
[Core] Implement equals and hashcode on CucumberFeature
mpkorstanje Dec 9, 2018
0b57d94
[Core] Re-encode string without re-reading resource
mpkorstanje Dec 9, 2018
6be5ad5
[Jupiter] Use uri in feature segment of UniqueId
mpkorstanje Dec 9, 2018
94fb513
[Jupiter] Reduce class visibility
mpkorstanje Dec 9, 2018
471266c
[Jupiter] Extract resource package
mpkorstanje Dec 9, 2018
3add6b1
Merge branch 'master' into junit-jupiter
mpkorstanje Dec 9, 2018
5b528bd
[Core] Revert encoding fix
mpkorstanje Dec 9, 2018
f5d1f40
[Jupiter] Polish
mpkorstanje Dec 9, 2018
674bdd0
[Jupiter] Polish
mpkorstanje Dec 9, 2018
f816c78
WIP
mpkorstanje Dec 13, 2018
35d39ca
Merge branch 'master' into junit-jupiter
mpkorstanje Jan 5, 2019
cbaf027
Merge branch 'master' into junit-jupiter
mpkorstanje Jan 5, 2019
fc11f6e
Merge branch 'master' into junit-jupiter
mpkorstanje Mar 2, 2019
6ec5514
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Mar 15, 2019
c0aba7c
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Sep 9, 2019
88ac92a
Add notes and stuff
mpkorstanje Sep 9, 2019
e263310
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Sep 9, 2019
1de09bf
More notes
mpkorstanje Sep 9, 2019
c838a34
Fix stuff
mpkorstanje Sep 10, 2019
dc7d926
Fix stuff
mpkorstanje Sep 10, 2019
4ae9854
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Sep 10, 2019
d52faed
Fix more
mpkorstanje Sep 10, 2019
2d35343
Fix more
mpkorstanje Sep 10, 2019
a758001
Clean up constants
mpkorstanje Sep 10, 2019
658d76f
Fix more classpath
mpkorstanje Sep 10, 2019
6c759e3
Notes
mpkorstanje Sep 10, 2019
370124b
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Sep 22, 2019
a9d2bd3
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Sep 26, 2019
2a18740
Fix moved packages
mpkorstanje Sep 26, 2019
c223986
Merge branch 'master' into junit-jupiter
mpkorstanje Oct 7, 2019
539f8ef
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Oct 12, 2019
069a023
Bump version
mpkorstanje Oct 12, 2019
e1e4321
Fix stuff
mpkorstanje Oct 12, 2019
36652fa
Map to test description usint recursive descent on ast
mpkorstanje Oct 13, 2019
db9d670
Clean up
mpkorstanje Oct 13, 2019
6ab7a02
Clean up
mpkorstanje Oct 13, 2019
7089f31
Clean up resource scanner
mpkorstanje Oct 13, 2019
6b9f9d1
Clean up resource scanner
mpkorstanje Oct 13, 2019
d68c394
Use lambda logging
mpkorstanje Oct 13, 2019
6003551
WIP
mpkorstanje Oct 13, 2019
f421cfe
WIP:
mpkorstanje Nov 14, 2019
5078ed3
WIP
mpkorstanje Nov 14, 2019
7298d6e
WIP
mpkorstanje Nov 15, 2019
45ca60c
Merge remote-tracking branch 'origin/master' into junit-jupiter
mpkorstanje Nov 15, 2019
93ea866
WIP
mpkorstanje Nov 15, 2019
251356a
WIP
mpkorstanje Nov 15, 2019
36c1995
WIP
mpkorstanje Nov 15, 2019
b668bc3
[Core] Replace ResourceIterable with standard Java solutions
mpkorstanje Nov 15, 2019
4083889
Merge branch 'refactor-resource-loading' into junit-jupiter
mpkorstanje Nov 15, 2019
aacd9b9
[Core] Classpath scanning inside nested Jars is not supported.
mpkorstanje Nov 16, 2019
43a423c
Merge branch 'refactor-resource-loading' into junit-jupiter
mpkorstanje Nov 16, 2019
13ddc64
Merge branch 'master' into junit-jupiter
mpkorstanje Nov 17, 2019
7495e33
Fix typos
mpkorstanje Nov 20, 2019
d580476
GroupId and artifactId are provided by default implemenation
mpkorstanje Nov 20, 2019
8181f64
Print snippets after test
mpkorstanje Nov 20, 2019
15abd83
Use ant to run Junit platform
mpkorstanje Nov 20, 2019
3b0aafc
Update readme
mpkorstanje Nov 20, 2019
22a65c8
Update readme
mpkorstanje Nov 20, 2019
166f31b
Update readme
mpkorstanje Nov 20, 2019
832b258
Add report output
mpkorstanje Nov 20, 2019
bd80d78
Make scenario and outline synonims
mpkorstanje Nov 21, 2019
1e3d12e
Update readme
mpkorstanje Nov 21, 2019
d857450
Clean up
mpkorstanje Nov 21, 2019
c12ce31
Use Gherkin compatibility objects to build feature descriptor
mpkorstanje Nov 21, 2019
200c080
Update readme
mpkorstanje Nov 21, 2019
7e255b2
Better example names
mpkorstanje Nov 21, 2019
06a48f5
Better example names
mpkorstanje Nov 21, 2019
1a940f8
Better module name
mpkorstanje Nov 21, 2019
b17e13c
Better module name
mpkorstanje Nov 21, 2019
17635fc
Fix concurrent reading of features
mpkorstanje Nov 21, 2019
31c05c7
Read jar files concurrently
mpkorstanje Nov 21, 2019
8319817
Use default class loaders util
mpkorstanje Nov 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cucumber.runtime.CucumberException;
import cucumber.runtime.StepDefinition;
import cucumber.runtime.StepDefinitionMatch;
import gherkin.pickles.PickleLocation;
import gherkin.pickles.PickleStep;
import io.cucumber.cucumberexpressions.CucumberExpressionException;
import io.cucumber.datatable.CucumberDataTableException;
Expand All @@ -15,10 +16,8 @@

class PickleStepDefinitionMatch extends Match implements StepDefinitionMatch {
private final StepDefinition stepDefinition;
private final transient String featurePath;
// The official JSON gherkin format doesn't have a step attribute, so we're marking this as transient
// to prevent it from ending up in the JSON.
private final transient PickleStep step;
private final String featurePath;
private final PickleStep step;

public PickleStepDefinitionMatch(List<Argument> arguments, StepDefinition stepDefinition, String featurePath, PickleStep step) {
super(arguments, stepDefinition.getLocation(false));
Expand Down Expand Up @@ -148,12 +147,17 @@ StepDefinition getStepDefinition() {
return stepDefinition;
}

PickleStep getStep() {
return step;
}

@Override
public String getCodeLocation() {
return stepDefinition.getLocation(false);
}

private static int getStepLine(PickleStep step) {
return step.getLocations().get(step.getLocations().size() - 1).getLine();
List<PickleLocation> locations = step.getLocations();
return locations.get(locations.size() - 1).getLine();
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/cucumber/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void addTestStepsForPickleSteps(List<PickleStepTestStep> testSteps, Pick
if (!snippets.isEmpty()) {
bus.send(new SnippetsSuggestedEvent(bus.getTime(), pickleEvent.uri, step.getLocations(), snippets));
}
match = new UndefinedPickleStepDefinitionMatch(step);
match = new UndefinedPickleStepDefinitionMatch(pickleEvent.uri, step);
}
} catch (AmbiguousStepDefinitionsException e) {
match = new AmbiguousPickleStepDefinitionsMatch(pickleEvent.uri, step, e);
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/cucumber/runner/TestStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ abstract class TestStep implements cucumber.api.TestStep {
private static final String[] ASSUMPTION_VIOLATED_EXCEPTIONS = {
"org.junit.AssumptionViolatedException",
"org.junit.internal.AssumptionViolatedException",
"org.testng.SkipException"
"org.testng.SkipException",
"org.opentest4j.TestAbortedException"
};

static {
Expand Down Expand Up @@ -85,9 +86,6 @@ private Result.Type mapThrowableToStatus(Throwable t) {
}

private Result mapStatusToResult(Result.Type status, Throwable error, long duration) {
if (status == Result.Type.UNDEFINED) {
return Result.UNDEFINED;
}
return new Result(status, duration, error);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
package cucumber.runner;

import io.cucumber.stepexpression.Argument;
import cucumber.api.Scenario;
import gherkin.pickles.PickleStep;
import io.cucumber.stepexpression.Argument;

import java.util.Collections;

class UndefinedPickleStepDefinitionMatch extends PickleStepDefinitionMatch {

UndefinedPickleStepDefinitionMatch(PickleStep step) {
super(Collections.<Argument>emptyList(), new NoStepDefinition(), null, step);
UndefinedPickleStepDefinitionMatch(String uri, PickleStep step) {
super(Collections.<Argument>emptyList(), new NoStepDefinition(), uri, step);
}

@Override
public void runStep(Scenario scenario) {
throw new UndefinedStepDefinitionException();
throw createUndefinedStepDefinitionException();
}

private UndefinedStepDefinitionException createUndefinedStepDefinitionException() {
UndefinedStepDefinitionException undefined = new UndefinedStepDefinitionException(getStep().getText());
undefined.setStackTrace(new StackTraceElement[]{getStepLocation()});
return undefined;
}

@Override
public void dryRunStep(Scenario scenario) throws Throwable {
public void dryRunStep(Scenario scenario) {
runStep(scenario);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cucumber.runner;

import cucumber.runtime.CucumberException;
final class UndefinedStepDefinitionException extends RuntimeException {

final class UndefinedStepDefinitionException extends CucumberException {

UndefinedStepDefinitionException() {
super("No step definitions found");
UndefinedStepDefinitionException(String stepText) {
super("Step not defined: '" + stepText + "'");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.util.Locale;

public class DefaultTypeRegistryConfiguration implements TypeRegistryConfigurer {
class DefaultTypeRegistryConfiguration implements TypeRegistryConfigurer {

@Override
public Locale locale() {
Expand Down
30 changes: 16 additions & 14 deletions core/src/main/java/cucumber/runtime/formatter/JSONFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void handleTestStepStarted(TestStepStarted event) {
currentBeforeStepHookList.clear();
}
currentStepsList.add(currentStepOrHookMap);
} else if(event.testStep instanceof HookTestStep) {
} else if (event.testStep instanceof HookTestStep) {
HookTestStep hookTestStep = (HookTestStep) event.testStep;
currentStepOrHookMap = createHookStep(hookTestStep);
addHookStepToTestCaseMap(currentStepOrHookMap, hookTestStep.getHookType());
Expand Down Expand Up @@ -262,7 +262,7 @@ private Map<String, Object> createTestStep(PickleStepTestStep testStep) {

private Map<String, Object> createDocStringMap(Argument argument) {
Map<String, Object> docStringMap = new HashMap<String, Object>();
PickleString docString = ((PickleString)argument);
PickleString docString = ((PickleString) argument);
docStringMap.put("value", docString.getContent());
docStringMap.put("line", docString.getLocation().getLine());
docStringMap.put("content_type", docString.getContentType());
Expand All @@ -271,7 +271,7 @@ private Map<String, Object> createDocStringMap(Argument argument) {

private List<Map<String, Object>> createDataTableList(Argument argument) {
List<Map<String, Object>> rowList = new ArrayList<Map<String, Object>>();
for (PickleRow row : ((PickleTable)argument).getRows()) {
for (PickleRow row : ((PickleTable) argument).getRows()) {
Map<String, Object> rowMap = new HashMap<String, Object>();
rowMap.put("cells", createCellList(row));
rowList.add(rowMap);
Expand Down Expand Up @@ -313,29 +313,29 @@ private void addHookStepToTestCaseMap(Map<String, Object> currentStepOrHookMap,
case AfterStep:
mapToAddTo = currentStepsList.get(currentStepsList.size() - 1);
break;
default:
mapToAddTo = currentTestCaseMap;
default:
mapToAddTo = currentTestCaseMap;
}

if (!mapToAddTo.containsKey(hookName)) {
mapToAddTo.put(hookName, new ArrayList<Map<String, Object>>());
}
((List<Map<String, Object>>)mapToAddTo.get(hookName)).add(currentStepOrHookMap);
((List<Map<String, Object>>) mapToAddTo.get(hookName)).add(currentStepOrHookMap);
}

private void addOutputToHookMap(String text) {
if (!currentStepOrHookMap.containsKey("output")) {
currentStepOrHookMap.put("output", new ArrayList<String>());
}
((List<String>)currentStepOrHookMap.get("output")).add(text);
((List<String>) currentStepOrHookMap.get("output")).add(text);
}

private void addEmbeddingToHookMap(byte[] data, String mimeType) {
if (!currentStepOrHookMap.containsKey("embeddings")) {
currentStepOrHookMap.put("embeddings", new ArrayList<Map<String, Object>>());
}
Map<String, Object> embedMap = createEmbeddingMap(data, mimeType);
((List<Map<String, Object>>)currentStepOrHookMap.get("embeddings")).add(embedMap);
((List<Map<String, Object>>) currentStepOrHookMap.get("embeddings")).add(embedMap);
}

private Map<String, Object> createEmbeddingMap(byte[] data, String mimeType) {
Expand All @@ -347,7 +347,7 @@ private Map<String, Object> createEmbeddingMap(byte[] data, String mimeType) {

private Map<String, Object> createMatchMap(TestStep step, Result result) {
Map<String, Object> matchMap = new HashMap<String, Object>();
if(step instanceof PickleStepTestStep) {
if (step instanceof PickleStepTestStep) {
PickleStepTestStep testStep = (PickleStepTestStep) step;
if (!testStep.getDefinitionArgument().isEmpty()) {
List<Map<String, Object>> argumentList = new ArrayList<Map<String, Object>>();
Expand All @@ -371,11 +371,13 @@ private Map<String, Object> createMatchMap(TestStep step, Result result) {
private Map<String, Object> createResultMap(Result result) {
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("status", result.getStatus().lowerCaseName());
if (result.getErrorMessage() != null) {
resultMap.put("error_message", result.getErrorMessage());
}
if (result.getDuration() != null && result.getDuration() != 0) {
resultMap.put("duration", result.getDuration());
if (!result.is(Result.Type.UNDEFINED)) {
if (result.getErrorMessage() != null) {
resultMap.put("error_message", result.getErrorMessage());
}
if (result.getDuration() != null && result.getDuration() != 0) {
resultMap.put("duration", result.getDuration());
}
}
return resultMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import cucumber.api.Result;
import cucumber.api.TestCase;
import cucumber.api.TestStep;
import cucumber.api.event.ConcurrentEventListener;
import cucumber.api.event.EventHandler;
import cucumber.api.event.EventListener;
import cucumber.api.event.EventPublisher;
Expand All @@ -31,6 +30,8 @@
import java.net.URI;
import java.util.List;

import static cucumber.api.Result.Type.UNDEFINED;

final class PrettyFormatter implements EventListener, ColorAware {
private static final String SCENARIO_INDENT = " ";
private static final String STEP_INDENT = " ";
Expand Down Expand Up @@ -170,13 +171,13 @@ private void handleStartOfFeature(TestCaseStarted event) {
private void handleScenarioOutline(TestCaseStarted event) {
TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, event.testCase.getLine());
if (TestSourcesModel.isScenarioOutlineScenario(astNode)) {
ScenarioOutline scenarioOutline = (ScenarioOutline)TestSourcesModel.getScenarioDefinition(astNode);
ScenarioOutline scenarioOutline = (ScenarioOutline) TestSourcesModel.getScenarioDefinition(astNode);
if (currentScenarioOutline == null || !currentScenarioOutline.equals(scenarioOutline)) {
currentScenarioOutline = scenarioOutline;
printScenarioOutline(currentScenarioOutline);
}
if (currentExamples == null || !currentExamples.equals(astNode.parent.node)) {
currentExamples = (Examples)astNode.parent.node;
currentExamples = (Examples) astNode.parent.node;
printExamples(currentExamples);
}
} else {
Expand Down Expand Up @@ -289,6 +290,7 @@ private void printFeature(String path) {
private void printTags(List<Tag> tags) {
printTags(tags, "");
}

private void printTags(List<Tag> tags, String indent) {
if (!tags.isEmpty()) {
out.println(indent + FixJava.join(FixJava.map(tags, tagNameMapper), " "));
Expand Down Expand Up @@ -333,6 +335,10 @@ private void printScenarioDefinition(TestCase testCase) {
}

private void printError(Result result) {
if (result.is(UNDEFINED)) {
return;
}

if (result.getError() != null) {
out.println(" " + formats.get(result.getStatus().lowerCaseName()).text(result.getErrorMessage()));
}
Expand Down
10 changes: 4 additions & 6 deletions core/src/main/java/cucumber/runtime/formatter/Stats.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cucumber.runtime.formatter;

import cucumber.api.Result;
import cucumber.api.PickleStepTestStep;
import cucumber.api.Result;
import cucumber.api.event.EventHandler;
import cucumber.api.event.EventListener;
import cucumber.api.event.EventPublisher;
Expand All @@ -11,10 +11,6 @@
import cucumber.api.event.TestStepFinished;
import cucumber.api.formatter.ColorAware;
import cucumber.api.formatter.StrictAware;
import cucumber.runtime.formatter.AnsiFormats;
import cucumber.runtime.formatter.Format;
import cucumber.runtime.formatter.Formats;
import cucumber.runtime.formatter.MonochromeFormats;

import java.io.PrintStream;
import java.text.DecimalFormat;
Expand All @@ -23,6 +19,8 @@
import java.util.List;
import java.util.Locale;

import static cucumber.api.Result.Type.UNDEFINED;

public class Stats implements EventListener, ColorAware, StrictAware {
static final long ONE_SECOND = 1000000000;
static final long ONE_MINUTE = 60 * ONE_SECOND;
Expand All @@ -47,7 +45,7 @@ public void receive(TestRunStarted event) {
@Override
public void receive(TestStepFinished event) {
Result result = event.result;
if (result.getError() != null) {
if (!result.is(UNDEFINED) && result.getError() != null) {
addError(result.getError());
}
if (event.testStep instanceof PickleStepTestStep) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
class FileResourceIterator implements Iterator<Resource> {
private final FlatteningIterator<Resource> flatteningIterator = new FlatteningIterator<Resource>();

static FileResourceIterator createFileResourceIterator(File root, File file, final String suffix) {
static Iterator<Resource> createFileResourceIterator(File root, File file, final String suffix) {
return new FileResourceIterator(root, file, suffix, false);
}

static FileResourceIterator createClasspathFileResourceIterator(File classpathRoot, File file, final String suffix) {
static Iterator<Resource> createClasspathFileResourceIterator(File classpathRoot, File file, final String suffix) {
return new FileResourceIterator(classpathRoot, file, suffix, true);
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/test/java/cucumber/runner/TestCaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class TestCaseTest {

@Test
public void run_wraps_execute_in_test_case_started_and_finished_events() throws Throwable {
doThrow(new UndefinedStepDefinitionException()).when(definitionMatch1).runStep(isA(Scenario.class));
doThrow(new UndefinedStepDefinitionException("step text")).when(definitionMatch1).runStep(isA(Scenario.class));

createTestCase(testStep1).run(bus);

Expand All @@ -79,7 +79,7 @@ public void run_all_steps() throws Throwable {

@Test
public void run_hooks_after_the_first_non_passed_result_for_gherkin_step() throws Throwable {
doThrow(new UndefinedStepDefinitionException()).when(definitionMatch1).runStep(isA(Scenario.class));
doThrow(new UndefinedStepDefinitionException("step text")).when(definitionMatch1).runStep(isA(Scenario.class));

TestCase testCase = createTestCase(testStep1, testStep2);
testCase.run(bus);
Expand All @@ -93,7 +93,7 @@ public void run_hooks_after_the_first_non_passed_result_for_gherkin_step() throw

@Test
public void skip_hooks_of_step_after_skipped_step() throws Throwable {
doThrow(new UndefinedStepDefinitionException()).when(definitionMatch1).runStep(isA(Scenario.class));
doThrow(new UndefinedStepDefinitionException("step text")).when(definitionMatch1).runStep(isA(Scenario.class));

TestCase testCase = createTestCase(testStep1, testStep2);
testCase.run(bus);
Expand All @@ -106,7 +106,7 @@ public void skip_hooks_of_step_after_skipped_step() throws Throwable {

@Test
public void skip_steps_at_first_gherkin_step_after_non_passed_result() throws Throwable {
doThrow(new UndefinedStepDefinitionException()).when(definitionMatch1).runStep(isA(Scenario.class));
doThrow(new UndefinedStepDefinitionException("step text")).when(definitionMatch1).runStep(isA(Scenario.class));

TestCase testCase = createTestCase(testStep1, testStep2);
testCase.run(bus);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
package cucumber.runner;

import cucumber.api.Scenario;
import gherkin.pickles.Argument;
import gherkin.pickles.PickleLocation;
import gherkin.pickles.PickleStep;
import org.junit.Test;

import java.util.Collections;

import static java.util.Collections.singletonList;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;

public class UndefinedStepDefinitionMatchTest {
public final UndefinedPickleStepDefinitionMatch match = new UndefinedPickleStepDefinitionMatch(mock(PickleStep.class));

@Test(expected=UndefinedStepDefinitionException.class)
public void throws_ambiguous_step_definitions_exception_when_run() throws Throwable {
private PickleStep pickleStep = new PickleStep("text", Collections.<Argument>emptyList(), singletonList(new PickleLocation(5, 5)));
public final UndefinedPickleStepDefinitionMatch match = new UndefinedPickleStepDefinitionMatch("path/to.feature", pickleStep);

@Test(expected = UndefinedStepDefinitionException.class)
public void throws_ambiguous_step_definitions_exception_when_run() {
match.runStep(mock(Scenario.class));
fail("UndefinedStepDefinitionsException expected");
}

@Test(expected=UndefinedStepDefinitionException.class)
public void throws_ambiguous_step_definitions_exception_when_dry_run() throws Throwable {
@Test(expected = UndefinedStepDefinitionException.class)
public void throws_ambiguous_step_definitions_exception_when_dry_run() {
match.dryRunStep(mock(Scenario.class));
fail("UndefinedStepDefinitionsException expected");
}
Expand Down
3 changes: 3 additions & 0 deletions examples/java-calculator-junit5/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.settings
/.classpath
/.project
Loading