AtlasCamp 2012 - Testing JIRA plugins smarter with TestKit


Published on

Slides from my lightning talk presented at AltasCamp 2012 about a hot new testing library useful for testing functionality of JIRA plugins.

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

AtlasCamp 2012 - Testing JIRA plugins smarter with TestKit

  1. 1. Photo by kc7fysTEST JIRA PLUGINS SMARTER JIRA TestKit
  2. 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. 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. 4. THE SOLUTION: REST-DRIVENTEST 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. 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. 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. 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. 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>
  9. 9. HOWTO - SETUP CONT.<dependency> <groupId>com.atlassian.jira.tests</groupId> <artifactId>jira-testkit-client</artifactId> <version>${testkit.version}</version> <scope>test</scope></dependency>
  10. 10. HOWTO - USING IN TESTpublic 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. 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. 12. HOW CAN I USE IT• Its hot and bleeding edge, still changing shape (right as I am speaking)• +integration+testing+with+TestKit• (planning to open-source it)•• plugin• JIRA Importers Plugin source code (bundled with JIRA src distro)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.