Description

Cucumber is a software testing tool that runs automated acceptance tests written in a behavior-driven development (BDD) style. BDD testing focuses on the behavior of the product. The Cucumber plugin imports the test results data into HCL Accelerate metrics.

Quick Info

Product
HCL Accelerate
Type
plugin
Compatibility
HCL Accelerate version 2.0 or later
Created by
HCL Software
Website
Version Name Action

1.0.7

ucv-ext-cucumber:1.0.7.tar

1.0.8

ucv-ext-cucumber:1.0.8.tar

ucv-ext-cucumber:1.0.7.tar

1.0.7


ucv-ext-cucumber:1.0.8.tar

1.0.8


Summary

The Cucumber plugin 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 contains a Java method linking to one or more scenario steps.

Compatibility

This plugin requires HCL Accelerate version 2.0 or later.

History

The following table describes the changes made in each plugin version.

Plugin history details
Version Description
1.0.8 Support Multiple Test Suites
1.0.7 Bug fix

Usage

To use the Cucumber plugin, the plugin must be loaded and an instance created. Load the plugin into the HCL Accelerate container if necessary. From the user interface, click Settings > Integrations > Plugins. On the Plugins page, locate the plugin and click Load Plugin. To create an instance, locate the plugin and click Install. The plugin is now listed below those plugins to be installed and available for invoking.

Integration type

The Cucumber plugin parses Cucumber data sent in a XML file. The plugin parses the *.xml file located in the target/surfire-reports directory generated by a Cucumber project.

Invoking the plugin

To gather data from the Cucumber server, 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 HCL Accelerate. You can use various methods such as Postman, REST calls, CURL, and CI/CD tools like Jenkins to invoke the plugin endpoints.

Invoke using Jenkins plugin

Install the Jenkin’s UrbanCode Velocity plugin into your Jenkins server. In your freestyle job or pipeline use the Upload Metrics File to HCL Accelerate step and provide the required fields. This step allows your build job to upload results files to HCL Accelerate.


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

Invoke using REST CALL

When using a REST call to invoke the plugin, it must be a POST method and include the location of the HCL Accelerate quality data endpoint.

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

  • Update the server location of HCL Accelerate in the URL.
  • The BODY of the call is a multipart/form data. It includes information about the payload.

METHOD: POST 
URL: https://<URL of HCL Accelerate Server>/reporting-consumer/metrics
BODY (multipart/form-data):
 {
  payload: <JSON Object>
  testArtifact: <cucumber_xml_file>
 }

Invoke using Curl


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

Payload schema

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


{
  "tenant_id": "",   
  "metricName": "", 
  "application": {
    "name": ""  
  },
  "record": {
    "recordName": "", 
    "executionDate": 1547983466015, 
    "pluginType": "cucumber",
    "dataFormat": "cucumberXML",  
    "metricsRecordUrl": "" 
  },
  "build": {  // One of the following fields must be included 
    "buildId": "",
    "jobExternalId": "",
    "url": "",
  },
  "commitId": "",  // optional
  "pullRequestId": "", // optional
  "environment": "" // optional
}
Name Description Required
tenant_id The name of the tenant. Yes
application_name The name of the application. Yes
metric_name The name of the recurring test set. Yes
commit_id No
pull_request_id No
environment_name No
Record section
record_name The name for this record No
execution_date The date that the test ran, specified in UNIX Epoch time. No
plugin_type This value must be cucumber. Yes
dataFormat xml file Yes
metricsRecordUrl To link the Jenkins build with test results No
Build section
build_id No
external_job_id No
build_url No