November 2018

A Plugin for Atlassian Jira – Wired Tests 1

12 December 2000
| |
Reading time: 2 minutes

Previous Page | Next Page | Pages: 0 1 2 3 4 5 6 7

Integration Tests

All integration tests are located under the package it.path.to.your.implementation – in this case, it.com.zuhlke.training.jira. These tests can only be run using the command atlas-integration-test or using the deprecated FastDev Console (see above).

Configuration for wired tests

Before you can use the context provider class in a wired test, you will have to import it to the test plugin as a component. And before you can do that, you’ll have to add annotations to export it appropriately. Add the following annotations to the MetricsInfoImpl class:


Add the following annotations to its constructor function:


The IDE will insert the following imports:

import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import com.zuhlke.training.jira.api.MetricsInfo;
import org.springframework.beans.factory.annotation.Autowired;
import javax.inject.Inject;
import javax.inject.Named;

Then add a component-import statement to the file src/test/resources/atlassian-plugin.xml:

<component-import key="metricsInfo" interface="com.zuhlke.training.jira.api.MetricsInfo"/>

Trivial Wired Test

We can now start using this class in wired tests. Start by creating the Java class MetricsInfoImplWiredTest. Annotate the class as follows:


This test runner requires a constructor with parameters corresponding to one or more of the component-imports quoted in the file src/test/resources/atlassian-plugin.xml. If you’re using an IDE, auto-generate the constructor and then change its signature to add the parameters, binding them to private final fields:

public MetricsInfoImplWiredTest(ApplicationProperties applicationProperties,
        MetricsInfo metricsInfo) {
    this.applicationProperties = applicationProperties;
    this.metricsInfo = metricsInfo;

You should now have these imports:

import com.atlassian.plugins.osgi.test.AtlassianPluginsTestRunner;
import com.atlassian.sal.api.ApplicationProperties;
import org.junit.runner.RunWith;

Now use the IDE code generator to create your first test:

public void shouldHaveCorrectInterfaces() {
    assertTrue("applicationProperties should be instance of ApplicationProperties",
            applicationProperties instanceof ApplicationProperties);
    assertTrue("metricsInfo should be instance of MetricsInfo",
            metricsInfo instanceof MetricsInfo);

The following imports are added:

import org.junit.Test;
import static org.junit.Assert.assertTrue;

This test case simply verifies that the parameters passed to the test class constructor conform to the expected type, proving that you have wired everything up correctly. To run the test, you need to make sure that the local Jira server is not running (type CTRL-D into its console if it is still up, and wait up to a minute for it to shut down). Then, at the root of your workspace, enter the command atlas-integration-test.

Previous Page | Next Page | Pages: 0 1 2 3 4 5 6 7

Comments (0)


Sign up for our Updates

Sign up now for our updates.

This field is required
This field is required
This field is required

I'm interested in:

Select at least one category
You were signed up successfully.

Receive regular updates from our blog


Or would you like to discuss a potential project with us? Contact us »