Tutorial - Smarter integration testing with TestKit
The source code of the plugin used in this tutorial is available in the Atlassian public source repository. You can get the source code from https://bitbucket.org/atlassian_tutorial/jira-testkit-example.
On this page:
Making JIRA ready for tests
Have you ever wondered how to set up complex test scenarios in JIRA? For example add multiple user accounts, groups and permissions, and check if your plugin correctly handles security constraints?
Have you ever been tired preparing different XML dumps for each configuration?
To solve problems like that you can use TestKit, our addition to test infrastructure that helps developers write integration tests with ease.
We've been using TestKit internally in JIRA for some time and as it matured and covered more and more features, we decided that it's time to share this with the ecosystem.
In the following document, we'll help you set up your plugin to use TestKit, and show you how to use it with some examples.
Benefits of using TestKit instead of FuncTestCase
As you probably noticed, FuncTestCase provides a lot of administrative methods through built-in administration attribute. You can still use them. They are all web-based, meaning that when you want to add a user, FuncTestCase goes to the page, fills in the form, submits it, and so on.
Instead TestKit talks with JIRA using REST, exchanging only crucial data to fullfil the task. It's a lot faster. And if you have many tests, you will notice the time difference when switching from FuncTestCase to TestKit.
Also TestKit is actively maintained and you can expect new features coming in.
Setting up the plugin
In your pom.xml search for maven-jira-plugin configuration, you need to extend it adding jira-testkit-plugin:
Also add jira-testkit-client to your project dependencies, remember to use it only with test scope:
Using TestKit in your tests
You learned in the previous sections about writing integration tests. Here's an example of an integration tests using TestKit:
In the above example you can notice how easy is to use TestKit. You can use data loading methods to populate JIRA with different configurations, then you can customize it further. Here we load a blank instance, then add a user, disable websudo and enable sub-tasks.
There's more - as you browse through the API you'll notice methods for managing permission schemes, projects, application properties, mail servers, dashboards, etc.