2. ORIGINAL PROBLEMS
•a lot of functional tests - their execution is really time
consuming (JIRA CI env uses 60+ remote agents and builds
still may take hours)
• opaque test fixtures - tons of XML dumps difficult to maintain
• most
of time spent by JWebUnit/HtmlUnit/Selenium/
WebDriver in UI not under test
• JUnit 3.x is 12 years old...
3. PROBLEM AMPLIFICATION
• With WebDriver and PageObjects writing functional tests got
too easy (at least superficially) and the number of them
exploded
• JIRA
is now developed by multiple teams and consists of
bundled plugins built and tested separately, but ... jira-func-tests
were not easily reusable easily outside JIRA core src tree -
especially against various JIRA versions.
4. THE SOLUTION: REST-DRIVEN
TEST FIXTURES AND ASSERTIONS
• order of magnitude faster than driven by UI
• less fragile (races, changes in UI)
• clear
and readable test fixture set-ups (no more opaque XML
dumps)
• stricter, more powerful and less fragile assertions
5. JIRA REST API
• Awesome (as of JIRA 5.0), but ... still limited
• Almost non-existent for administrative operations
• Use whenever you can
• JRJC(JIRA REST Java Client) makes using REST API from Java
very easy
6. BACKDOOR
• Unofficial dev-only JIRA REST API providing missing
functionalities
• Originally part of JIRA source tree (unavailable for mortals)
• Veryeasy to extend and consume: very lightweight lifecycle, no
need to care too much about long-term commitments,
security, ideal shape of representations, HTTP return codes, etc.
• Comes with *Control classes, which allow to easily do remote
calls from Java
7. JIRA TESTKIT
• Backdoor for the Ecosystem
• Consists of two parts:
• JIRA Plugin deployed only during tests and exposing additional
REST resources
• Java client library talking remotely to JIRA and using these
additional REST resources
• We hope promote most useful resources from Backdoor to the
official JIRA REST API
8. HOW TO - SETUP
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<configuration>
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
</configuration>
<plugin>
10. HOWTO - USING IN TEST
public class MyPluginTest extends FuncTestCase {
@Override
protected void setUpTest() {
super.setUpTest();
Backdoor testKit = new Backdoor(
new TestKitLocalEnvironmentData());
testKit.restoreBlankInstance(
TimeBombLicence.LICENCE_FOR_TESTING);
testKit.usersAndGroups().addUser("test-user");
testKit.websudo().disable();
testKit.subtask().enable();
// ...
}
// ...
}
11. public class TestBugzillaImporter extends TestBase {
private JiraRestClient restClient;
@Before
public void setUpTest() {
backdoor().restoreBlankInstance();
backdoor().attachments().enable();
backdoor().timeTracking().enable("8", "5", TimeTracking.Format.PRETTY,
TimeTracking.Unit.HOUR, TimeTracking.Mode.MODERN);
restClient = ITUtils.createRestClient(jira().environmentData());
}
@Test
public void someTest() {
// execute your test using Page Objects / WebDriver
// ...
// maybe you need some special license
assertTrue(backdoor().license().switchToPersonalLicense());
// ...
// maybe it should create a user and put it into an appropriate group
assertTrue(backdoor().usersAndGroups().userExists("mytestuser"));
assertTrue(backdoor().usersAndGroups().isUserInGroup("mytestuser", "jira-users"));
// maybe it creates a JIRA issue
final Issue issue = restClient.getIssueClient().getIssue("TES-19",
new NullProgressMonitor());
assertEquals("expectedreporter", issue.getReporter().getName());
assertEquals("expectedassignee", issue.getAssignee().getName());
}
}
12. HOW CAN I USE IT
• It's hot and bleeding edge, still changing shape (right as I am speaking)
• https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter
+integration+testing+with+TestKit
• https://bitbucket.org/atlassian/jira-testkit/ (planning to open-source it)
• https://bitbucket.org/atlassian/jira-testkit-example
• https://marketplace.atlassian.com/plugins/com.atlassian.jira.tests.jira-testkit-
plugin
• JIRA Importers Plugin source code (bundled with JIRA src distro)