Tutorial: Invoking test cases from Jenkins with JUnit result format
Before you begin
You must have the Automated API behavior testing application enabled and have created and published at least one test. You must have a Jenkins instance that you can create a new build in with the JUnit Plugin installed
About this tutorial
In this tutorial, you invoke a test case using injected variables from a jenkins pipeline
This tutorial takes you through the following steps
- Creating an API Hook
- Creating an API Key and Secret
- Creating a Jenkins build that invokes the API Hook
- Executing the build and reviewing the test results
Creating an API Hook
Creating an API Key and Secret
Creating a Jenkins build that invokes the API Hook
-
Create a Jenkins Project or navigate to an existing one
-
Select
Configure
from the the options
-
Under
Build
, clickAdd build step
dropdown and selectExecute Shell
-
Within the
Execute shell
block paste acurl
command that will invoke the hook that was created in step 1curl -XPOST -H 'x-api-key: <API-KEY>' -H 'x-api-secret: <API-SECRET>' -H "Content-type: application/json" -d '{ options: { JUnitFormat: true }}' '<API-HOOK-URL>/tests/run' >| testReports.xml
-
Under
Post-build Actions
, clickAdd post-build action
and in the dropdown selectPublish JUnit test results report
.- For
Test report XMLs
provide the name of the report created from the curl, in this tutorialtestReports.xml
- For
-
Save the project
Executing the build and reviewing the test results
- Click
Build Now
on the project
- Once the build has completed, you will now see a chart showing
- Click
Latest Test results
and review the Junit results
To expand upon this tutorial additional options and steps can be found under Using API Hooks
What you did in this tutorial
In this tutorial you completed the following activities:
- Created a API Hook
- Created a Key and Secret used for authenicating with a hook
- Invoked the API Hook using the Key and Secret to start a test and process the results