-
Notifications
You must be signed in to change notification settings - Fork 149
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
Showing
4 changed files
with
128 additions
and
37 deletions.
There are no files selected for viewing
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.
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
72 changes: 72 additions & 0 deletions
72
...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,72 @@ | ||
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.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Text; | ||
import org.eclipse.ui.dialogs.PropertyPage; | ||
import org.osgi.service.prefs.BackingStoreException; | ||
|
||
import io.cucumber.eclipse.editor.Images; | ||
|
||
public class CucumberPropertiesPage extends PropertyPage { | ||
|
||
private static final String NAMESPACE = "io.cucumber.eclipse.editor"; | ||
private static final String KEY_VALIDATION_PLUGINS = "validationPlugins"; | ||
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); | ||
Label label = new Label(composite, SWT.NONE); | ||
label.setText("Validation Plugins "); | ||
label.setToolTipText( | ||
"Add a comma seperated list of plugins that should be used for validation regardless of feature settings"); | ||
validationPlugins = new Text(composite, SWT.BORDER); | ||
GridData data = new GridData(GridData.FILL_HORIZONTAL); | ||
validationPlugins.setLayoutData(data); | ||
return composite; | ||
} | ||
|
||
@Override | ||
public boolean performOk() { | ||
IEclipsePreferences node = getNode(getResource()); | ||
node.put(KEY_VALIDATION_PLUGINS, validationPlugins.getText()); | ||
try { | ||
node.flush(); | ||
} catch (BackingStoreException e) { | ||
} | ||
return true; | ||
} | ||
|
||
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; | ||
} | ||
|
||
} |