While automated tests have a value of their own, integrating them in your CI flow can have a significant impact on your product’s overall quality. Ensuring that your automation (or at least part of it) will be executed each time there is a version build, will provide much broader insights into the stability of the product. TestProject test automation platform allows easy integration with Jenkins CI by using a simple Jenkins plugin.
This article will guide you step by step through the process of setting TestProject-Jenkins integration.
- You need to have a TestProject account. Don’t worry, it’s FREE.
- Jenkins CI server up and running.
- Installing TestProject Jenkins Plugin
- Creating a TestProject API Key
- Configuring the TestProject Jenkins Plugin
- Running a TestProject Job from Jenkins
- Reviewing Execution Results
TestProject’s Jenkins plugin is available in the Jenkins plugin index and is simply installed from Jenkins UI.
- Open your favorite browser and navigate to your Jenkins server.
- Choose Manage Jenkins → Manage Plugin → Available Tab.
- Filter “TestProject” → Select TestProject plugin and hit Install without Restart.
That’s it! After a few seconds, the plugin will be installed in your Jenkins server.
Now it’s time to integrate TestProject. For that, you will have to create an API key that your Jenkins server will use to trigger your automation jobs.
- Open the TestProject application and go to Developers → API.
- Create a new API key (let’s call it Jenkins) and grant it the access you desire. API keys can have unrestricted access which means that they can be used in any project or have access to specific projects (this option is only available to account administrators and no worries, you can always edit the permissions later).
- After the new API key has been created, copy it and head back to your Jenkins server.
Now let’s configure the TestProject Jenkins plugin and set the newly created API key. This is a one-time step (unless you wish to change your key at some point), your key will be used for every job triggered by a Jenkins build.
- In Jenkins, choose Manage Jenkins → Configure System.
- Locate the TestProject configuration section, paste your key into the API Key field and hit Save.
After installing the TestProject Jenkins plugin, generating an API key and configuring it to be used by Jenkins, you are ready to go ahead and incorporate your automated tests in the CI process. The plugin supports the two most popular approaches: Freestyle & Pipeline.
In order to run a TestProject job remotely, all you need besides the API key which we’ve already configured are the Project ID and the Job ID which you want to run. These IDs are unique strings and the easiest way to obtain them is by using TestProject application UI. To get the ID of the project just navigate to the homepage and copy the ID from the project’s context menu. The job ID is available in its context menu as well.
Note: If you cannot locate the Copy ID option is your menus, please make sure that you have at least one API key defined in the account.
Now let’s head back to Jenkins and create a new CI job or open an existing one.
For freestyle projects:
- Add a new TestProject Job build step:
- Provide the parameters to be used and save:
For pipeline projects use the following syntax:
runtpjob jobId: 'YOUR_JOB_ID', projectId: 'YOUR_PROJECT_ID', waitJobFinishSeconds: 1800
The wait parameter is optional in both cases. The valid values are 0 or 10 and higher (the value is in seconds):
- Setting the value to 0 or omitting the parameter in the pipeline will run the TestProject job without waiting for it to finish. The result of the TestProject job will not affect the result of the Jenkins job.
- Setting the value to 10+ will wait for TestProject job to finish within the defined time frame. In case the automation didn’t finish running in the defined period or the tests failed, the Jenkins job will be marked failed as well.
After the execution completes, you will see console entries regarding the execution process. At the end, a direct link to the generated report will be present.
TestProject report of the executed job will reflect the Jenkins CI build information.
In this article, we’ve installed TestProject‘s plugin for Jenkins CI, added a step to run our automated jobs and reviewed the results. There is no doubt that CI tools like Jenkins have revolutionized the way we build and deploy our software. These tools dramatically shortened the time span between introducing a new feature or a bug fix to our product and the time the new version is ready to be tested/used. Test automation allows us to increase the coverage of what is being tested in every new release which in turn improves the quality of our software. Incorporating test automation into the CI process takes another step towards better, more stable products!
Feel free to leave your comments below ➡