Description
JUnit provides a testing framework for the Java programming language. The JUnit plug-in imports the test results data into HCL DevOps Velocity metrics dashboard.
JUnit provides a testing framework for the Java programming language. The JUnit plug-in imports the test results data into HCL DevOps Velocity metrics dashboard.
The JUnit plug-in provides for integration with a JUnit server. Data is uploaded to the HCL DevOps Velocity server using an HTTP Post request.
To integrate the plug-in using the user interface, perform the following steps:
In HCL DevOps Velocity, click Settings > Integrations > Installed.
In the Action column for the JUnit plug-in, click Add Integration.
On the Add Integration dialog, enter the values for the fields to configure the integration and define communication.
Click Add.
The JUnit plug-in is a parser type plug-in . It parses JUnit XML data.
To gather data from the JMeter server, send an HTTP Post request with the data to parse. Whenever there is a hit to the endpoint, the data is parsed and displayed as metrics in HCL DevOps Velocity. You can use various methods such as Postman, REST calls, CURL, and CI/CD tools like Jenkins to invoke the plug-in endpoints.
Install the HCL DevOps Velocity plugin into your Jenkins server. In your freestyle job or pipeline use the UCV-Upload Metrics File to HCL DevOps Velocity step and provide the required fields. This step allows your build job to upload generated coverage results files to HCL DevOps Velocity.
pipeline {
agent any
stages {
stage('junitMetrics') {
steps {
step([$class: 'UploadMetricsFile', appName: 'My Junit Test', dataFormat: 'junitXML', filePath: '<location of the junit report>', name: 'my-junit-test', pluginType: 'junitXML', tenantId: '<tenant Id>', testSetName: 'junit', metricsRecordUrl: "${env.BUILD_URL}"])
}
}
}
}
When using a REST call to invoke the Code Coverage plug-in, it must be a POST method and include the location of the HCL DevOps 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:
METHOD: POST
URL: https://<url_devopsvelocity_server>/reporting-consumer/metrics
BODY (multipart/form-data):
{
payload: <payload_json_object_string> // See below for schema format
testArtifact: <junit_xml_file>
}
curl --request POST \
--url https://url_devopsvelocity_server>/reporting-consumer/metrics \
--form 'payload={
"tenant_id": "",
"application": {
"name": "My Application"
},
"record": {
"pluginType": "junitXML",
"dataFormat": "junitXML"
}
}
' \
--form testArtifact=@test-result/junit.xml
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": "junitXML",
"dataFormat": "junitXML",
"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
}
Uploaded: 05-Jul-2024 07:40
docker pull hclcr.io/accelerate/ucv-ext-junit:1.0.84
Uploaded: 12-Jun-2024 09:34
Uploaded: 27-May-2022 04:37
docker pull hclcr.io/accelerate/ucv-ext-junit:1.0.72
Uploaded: 29-Sep-2021 05:29
docker pull hclcr.io/accelerate/ucv-ext-junit:1.0.66
Uploaded: 08-Feb-2021 07:38
docker pull hclcr.io/accelerate/ucv-ext-junit:1.0.38