diff --git a/cucumber.eclipse.editor/src/main/java/cucumber/eclipse/editor/builder/CucumberGherkinBuilder.java b/cucumber.eclipse.editor/src/main/java/cucumber/eclipse/editor/builder/CucumberGherkinBuilder.java index 486f418a..36277eb8 100644 --- a/cucumber.eclipse.editor/src/main/java/cucumber/eclipse/editor/builder/CucumberGherkinBuilder.java +++ b/cucumber.eclipse.editor/src/main/java/cucumber/eclipse/editor/builder/CucumberGherkinBuilder.java @@ -353,8 +353,14 @@ public void scenarioOutline(ScenarioOutline scenarioOutline) { @Override public void examples(Examples examples) { ExamplesTableRow examplesHeader = examples.getRows().get(0); + int variablesSize = examplesHeader.getCells().size(); for (int i = 1; i < examples.getRows().size(); i++) { ExamplesTableRow currentExample = examples.getRows().get(i); + int examplesSize = currentExample.getCells().size(); + if (examplesSize != variablesSize) { + markerFactory.syntaxErrorOnGherkin(gherkinFile, "The number of examples ("+examplesSize+")does not match the number of variables ("+variablesSize+")", currentExample.getLine()); + continue; + } try { matchScenarioOutlineExample(examplesHeader, currentExample); } catch (CoreException e) { diff --git a/cucumber.eclipse.steps.integration/src/main/java/cucumber/eclipse/steps/integration/marker/MarkerFactory.java b/cucumber.eclipse.steps.integration/src/main/java/cucumber/eclipse/steps/integration/marker/MarkerFactory.java index 13781da2..d7c99aa7 100644 --- a/cucumber.eclipse.steps.integration/src/main/java/cucumber/eclipse/steps/integration/marker/MarkerFactory.java +++ b/cucumber.eclipse.steps.integration/src/main/java/cucumber/eclipse/steps/integration/marker/MarkerFactory.java @@ -180,13 +180,19 @@ public void syntaxErrorOnGherkin(IResource stepDefinitionResource, Exception e) public void syntaxErrorOnGherkin(final IResource gherkinResource, final Exception e, final int lineNumber) { + syntaxErrorOnGherkin(gherkinResource, e.getMessage(), lineNumber); + + } + + public void syntaxErrorOnGherkin(final IResource gherkinResource, String msg, final int lineNumber) { + this.mark(gherkinResource, new IMarkerBuilder() { @Override public IMarker build() throws CoreException { IMarker marker = null; marker = gherkinResource.createMarker(GHERKIN_SYNTAX_ERROR); marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); - marker.setAttribute(IMarker.MESSAGE, e.getMessage()); + marker.setAttribute(IMarker.MESSAGE, msg); marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); return marker; }