Plug-in Documentation

Cucumber

Overview


The Cucumber plug-in automates running Cucumber test scenarios. Test scenarios are based on Behavior Driven Development (BDD) written to test product features.

Cucumber test scenarios are written using the Gherkin syntax. Each scenario contains a set of steps that are verified processed by the Cucumber tool. A report of success or failure is generated for each scenario. Scenarios are stored as .feature text files. Step Definitions, referred to as glue contain a Java method linking to one or more scenario steps.

Compatibility

Must be running UrbanCode Velocity version 1.4.5 and later to use the plug-in.

Versions

There is no install process for this plug-in. The Cucumber plug-in is identified to UrbanCode Velocity as a value stream integration. UrbanCode Velocity plug-in images are located in DockerHub and the UrbanCode Velolcity code accesses the version that you select. To view available versions, see the UrbanCode DockerHub.

History

Version 1.0.6

  • Minor bug fix.

Version 1.0.3

  • Initial release.

Usage


The Cucumber plug-in does not require configuration, like other types of UrbanCode Velocity plug-ins. To use the plug-in send an HTTP Post request with the data to parse. Whenever a there is a hit to the endpoint, the data is parsed and displayed as metrics in UrbanCode Velocity.

Integration type

The Cucumber plug-in is a parser type plug-in. It parses Cucumber data sent in a XML file. The plug-in parses the *.xml file located in the target/surfire-reports directory generated by the Cucumber project.

Invoking the plug-in

You can invoke the plug-in manually using a REST Call or by using a Jenkins plug-in to integrate UrbanCode Velocity in a Jenkins environment.

Invoke using Jenkins plug-in

Install the UrbanCode Velocity plug-in into your Jenkins server. In your freestyle job or pipeline use the UCV-Upload Metrics File to UrbanCode Velocity step and provide the required fields. This step allows your build job to upload generated coverage results files to UrbanCode Velocity.

Example


pipeline {
   agent any
   stages {
      stage('cucumberMetrics') {
         steps {
            step([$class: 'UploadMetricsFile',  appName: 'My Cucumber Test', dataFormat: 'cucumberXML', filePath: '<location of the cucumber report>', name: 'my-cucumber-test', pluginType: 'cucumber', tenantId: '<tenant Id>', testSetName: 'cucumber', metricsRecordUrl: "${env.BUILD_URL}"])
         }
      }
   }
}

Invoke the plug-in using a Rest call

When using a REST call to invoke the Cucumber plug-in, it must be a POST method and include the location of the UrbanCode Velocity quality data endpoint.

The following request sample shows a REST call that you can copy and update as necessary. Key points about the snippet:

  • The URL points to the UrbanCode Velocity quality data endpoint. Update with the server location for your installation of UrbanCode Velocity.
  • The BODY of the call is a multipart/form data. It includes information about the payload.

METHOD: POST 
URL: https://<url_urbancodevelocity_server>/reporting-consumer/metrics 
BODY (multipart/form-data):
 {
  payload: <payload_json_object_string> // See below for schema format
 testArtifact: <cucumber_xml_file>
 }

The following shows the schema for the payload. Replace the angle brackets with your values for the parameters.


{
  "tenant_id": "<tenant_id>",    // required Tenant ID
  "metricName": "<metric_name>", // optional: name for recurring test set
  "application": {
    "name": "<application_name>"  //Name of application
  },
  "record": {
    "recordName": "<record_name>", // optional: Name for this record
    "executionDate": 1547983466015, // optional: UNIX Epoch
    "pluginType": "cucumber",
    "dataFormat": "cucumberXML",  // xml file
    "metricsRecordUrl": "<Jenkins_build_url>" // optional: To link the Jenkins build with test results
  },
  "build": {  // Optional: One of the following fields must be included 
    "buildId": "<build_id>",
    "jobExternalId": "<external_job_id>",
    "url": "<build_url>",
  },
  "commitId": "<commit_id>",  // optional
  "pullRequestId": "<pullrequest_id>", // optional
  "environment": "<environment_name>" // optional
}

Example


curl --request POST \
  --url https://url_urbancodevelocity_server>/reporting-consumer/metrics \
  --form 'payload={
    "tenant_id": "5ade13625558f2c6688d15ce",
    "application": {
    "name": "My Application"
  },
  "record": {
    "pluginType": "cucumber",
    "dataFormat": "cucucmberXML"
  }
}
' \
  --form testArtifact=@test-result/cucumber.xml