Cukestyle plugin

Plugin that checks the compliance of BDD feature files (cucumber java) against configurable list of rules.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.github.saiprasadkrishnamurthy
ArtifactId

ArtifactId

cuke-style-maven-plugin
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Cukestyle plugin
Plugin that checks the compliance of BDD feature files (cucumber java) against configurable list of rules.
Project URL

Project URL

https://github.com/SaiprasadKrishnamurthy/cukestyle-maven-plugin
Source Code Management

Source Code Management

https://github.com/SaiprasadKrishnamurthy/cukestyle-maven-plugin

Download cuke-style-maven-plugin

How to add to project

<plugin>
    <groupId>com.github.saiprasadkrishnamurthy</groupId>
    <artifactId>cuke-style-maven-plugin</artifactId>
    <version>1.0</version>
</plugin>

Dependencies

compile (10)

Group / Artifact Type Version
org.codehaus.jackson : jackson-mapper-asl jar 1.9.13
org.slf4j : slf4j-simple jar 1.7.7
net.serenity-bdd : serenity-cucumber jar 1.0.15
info.cukes : gherkin jar 2.12.2
com.google.guava : guava jar 18.0
com.fasterxml.jackson.core : jackson-databind jar 2.5.4
org.apache.maven : maven-plugin-api jar 3.3.3
commons-io : commons-io jar 2.4
org.apache.maven : maven-project jar 3.0-alpha-2
org.reflections : reflections jar 0.9.10

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.hamcrest : hamcrest-all jar 1.3

Project Modules

There are no modules declared in this project.

CukeStyle Maven Plugin

This is a simple extensible cucumber feature files rules checker maven plugin. This currently only supports Cucumber (Java) as a Gherkin implementation. The rules are defined in a json file which is fed into the plugin for checking. More rules can be added in the future without modifying the existing rule implementations.

A sample rules json file would typically look like this.

[
  {
    "ruleId": "UNUSED_STEP_DEFS",
    "ruleDescription": "Number of unused Java step definitions",
    "ruleSeverity": "HIGH",
    "maxThreshold": 0
  },
  {
    "ruleId": "CONJUNCTIONS",
    "ruleDescription": "Number of conjunctions 'and' in a a step",
    "ruleSeverity": "HIGH",
    "minThreshold": 0,
    "maxThreshold": 5
  },
  {
    "ruleId": "EXAMPLES_LIMIT",
    "ruleDescription": "Number of examples in a data table",
    "ruleSeverity": "HIGH",
    "minThreshold": 0,
    "maxThreshold": 10
  }
]

The basic usage is to hook this plugin during the prepare-package phase (before the Functional Tests) are run and get a report of the issues (if any).

To hook this plugin into the pom of the functional tests, the following must be done.

        <plugin>
             <groupId>com.github.saiprasadkrishnamurthy</groupId>
             <artifactId>cuke-style-maven-plugin</artifactId>
             <version>1.0</version>
            <configuration>
                <rulesFilePath>rules.json</rulesFilePath>
                <baseStepDefsPackage>features.steps</baseStepDefsPackage>
                <baseFeatureFilesDir>target/test-classes</baseFeatureFilesDir>
            </configuration>
            <executions>
                <execution>
                    <id>check</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

All the configuration parameters are self explanatory.

An example table is output on the command line as a result of the checks

[INFO] --- cuke-style-maven-plugin:1.0-SNAPSHOT:check (check) @ ui-functional-tests ---
[INFO] Going to check the feature files against the rules: /Users/sai/ui-functional-tests/ui-functional-tests/rules.json
+------------------+----------+--------------------------------------------------------------------------------------------------------+
|       RULE       | SEVERITY |                                              ERROR_MESSAGE                                             |
+------------------+----------+--------------------------------------------------------------------------------------------------------+
|   EXAMPLES_LIMIT |     HIGH |                                                                      /footer.feature (Max allowed: 10) |
|   EXAMPLES_LIMIT |     HIGH |                                                                     /meganav.feature (Max allowed: 10) |
| UNUSED_STEP_DEFS |     HIGH |                   features.steps.CommonPageSteps::link_for_respective_address_should_be_displayed(...) |
| UNUSED_STEP_DEFS |     HIGH |                                         features.steps.CommonPageSteps::links_should_be_displayed(...) |
| UNUSED_STEP_DEFS |     HIGH |            features.steps.ProductDetailsLegacyPageSteps::i_add_a_product_to_the_localised_trolley(...) |
| UNUSED_STEP_DEFS |     HIGH | features.steps.ProductDetailsLegacyPageSteps::i_add_a_product_to_the_localised_OutOfStock_trolley(...) |
+------------------+----------+--------------------------------------------------------------------------------------------------------+

[INFO] Cukestyle Reports generated successfully in /Users/sai/ui-functional-tests/ui-functional-tests/target/cuckestyle_results.csv

For Rule Implementors

Every rule must have an unique ID defined in the "ruleId" field of the JSON. Once you have chosen the ID, you will just need to implement a new rule just by extending the DefaultRule.

All the wiring of the rules would happen automatically.

Versions

Version
1.0