-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a project config option to have validators for all features
Currently a validator has to be configured for each feature, if one wants to validate all features in a project this become cumbersome. This adds a configuration option to enable validators for the whole project.
- Loading branch information
Christoph Läubrich
committed
Jun 2, 2024
1 parent
803758c
commit 72b324d
Showing
11 changed files
with
359 additions
and
192 deletions.
There are no files selected for viewing
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
134 changes: 0 additions & 134 deletions
134
....backends.java/src/cucumber/eclipse/backends/java/properties/JavaBackendPropertyPage.java
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...lipse.editor/src/main/java/cucumber/eclipse/editor/properties/CucumberPropertiesPage.java
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
examples/java-datatable/.settings/cucumber.backend.java.prefs
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,2 @@ | ||
eclipse.preferences.version=1 | ||
validationPlugins=cucumber.examples.datatable.GlobalValidator |
24 changes: 24 additions & 0 deletions
24
examples/java-datatable/src/main/java/cucumber/examples/datatable/GlobalValidator.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,24 @@ | ||
package cucumber.examples.datatable; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import io.cucumber.plugin.Plugin; | ||
|
||
/** | ||
* This validator is enabled globally in the preferences | ||
*/ | ||
public class GlobalValidator implements Plugin { | ||
|
||
private ConcurrentHashMap<Integer, String> errors = new ConcurrentHashMap<>(); | ||
|
||
public GlobalValidator() { | ||
errors.put(1, "Tis is an error from the global validator, but you can't do anything about it!"); | ||
} | ||
|
||
// This is a magic method called by cucumber-eclipse to fetch the final errors and display them in the document | ||
public Map<Integer, String> getValidationErrors() { | ||
return errors; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
examples/java-datatable/src/test/resources/cucumber/examples/datatable2.feature
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,47 @@ | ||
#language: en | ||
#This Feature has no validator enabled in the feature file but in the project preferences! | ||
Feature: Connection between DataTable Key and a specific Step Value | ||
|
||
|
||
Scenario: All Keys are related to a Step Value. Example 1 | ||
Given the animal "Cat" | ||
| Key | Value | | ||
| Color | Black | | ||
| Lifespan | 3 | | ||
| Whiskers | 24 | | ||
|
||
Then the food is "fish" | ||
|
||
|
||
Scenario: All Keys are related to a Step Value. Example 2 | ||
Given the animal "Elephant" | ||
| Key | Value | | ||
| Color | Grey | | ||
| Lifespan | 70 | | ||
| Trunk | 1.8 | | ||
| Tusk | 1.3 | | ||
|
||
Then the food is "leaves" | ||
|
||
|
||
Scenario: There are some unrelated Keys to a Step Value. This Keys are available for other Step Value | ||
Given the animal "Cat" | ||
| Key | Value | | ||
| Color | Black | | ||
| Lifespan | 3 | | ||
| Whiskers | 24 | | ||
| Trunk | 1.8 | | ||
|
||
Then the food is "fish" | ||
|
||
|
||
Scenario: There are some unrelated Keys to a Step Value. This Keys are not available for each Step Value | ||
Given the animal "Cat" | ||
| Key | Value | | ||
| Color | Black | | ||
| Lifespan | 3 | | ||
| Whiskers | 24 | | ||
| Wings | 2 | | ||
|
||
Then the food is "fish" | ||
|
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
50 changes: 50 additions & 0 deletions
50
...mber.eclipse.editor/src/io/cucumber/eclipse/editor/properties/CucumberPropertiesPage.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,50 @@ | ||
package io.cucumber.eclipse.editor.properties; | ||
|
||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.resources.ProjectScope; | ||
import org.eclipse.core.runtime.preferences.IEclipsePreferences; | ||
import org.eclipse.jface.preference.PreferencePage; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Text; | ||
import org.eclipse.ui.dialogs.PropertyPage; | ||
|
||
import io.cucumber.eclipse.editor.Images; | ||
|
||
public class CucumberPropertiesPage extends PropertyPage { | ||
|
||
private static final String NAMESPACE = "io.cucumber.eclipse.editor"; | ||
private Text validationPlugins; | ||
|
||
public CucumberPropertiesPage() { | ||
setTitle("Cucumber"); | ||
setDescription("You can configure Cucumber related properties for your project here"); | ||
setImageDescriptor(Images.getCukesIconDescriptor()); | ||
noDefaultAndApplyButton(); | ||
} | ||
|
||
/** | ||
* @see PreferencePage#createContents(Composite) | ||
*/ | ||
@Override | ||
protected Control createContents(Composite parent) { | ||
Composite composite = new Composite(parent, SWT.NONE); | ||
GridLayout layout = new GridLayout(); | ||
layout.numColumns = 2; | ||
composite.setLayout(layout); | ||
return composite; | ||
} | ||
|
||
private IResource getResource() { | ||
return getElement().getAdapter(IResource.class); | ||
} | ||
|
||
public static IEclipsePreferences getNode(IResource resource) { | ||
ProjectScope scope = new ProjectScope(resource.getProject()); | ||
IEclipsePreferences node = scope.getNode(NAMESPACE); | ||
return node; | ||
} | ||
|
||
} |
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
Oops, something went wrong.