Automated testing for groovy scripts (script runner + behaviours plugins)

Nathon Fowlie May 25, 2014

I'm currently managing a large JIRA instance that has a large number of groovy scripts to enforce particular business process etc. Every time a change is made myself and others have to spend a large amount of time manually testing changes and it's leading to alot of human error (easy to miss edge cases etc).

Some of the scripts also need to be bulletproof because business effectively would stop if they broke, so I need a robust, consistent way to confirm they do what they're supposed to and that changes don't have unintended consequences.

I was wondering if it's possible to build unit, functional & regression tests for groovy scripts that run inside the Script Runner & Behaviours plugins? Not sure if it really makes any difference but the scripts are a mix of scripted event listeners, post functions and field validators, with a small amount of data being pulled from an external database.

3 answers

1 accepted

4 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2014

Agree with Bob although not necessarily about the mechanism. Personally, I have a maven dev profile that includes junit and spock, and it will search out unit tests so they can be run from within jira. I've tried many approaches including mocking, and the SDKs own integration test runner, and imho this is by far the fastest for development as it doesn't require any plugin compilation and upload.

These also include tests that do as Bob suggest, create issue, move through workflow etc. Where possible I test without that baggage though.

I might look into making this available if it might be helpful. The reason why I haven't is because including junit, spock, geb and webdriver makes the plugin much chunkier.

But you could just write a groovy script that drives an issue through the workflow, and test the expected outcomes at each point, being sure to test the edge cases you're talking about. You'd then run this from the admin console after making changes. Not ideal but better than nothing.

3 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2014

It is much easier to run integration tests on a test instance (or at least test projects) than worring about the insides of various plugins etc... You want to ensure the business process works no matter whether it is a plugin or configuration issue. For instance, creating issues and moving them through the work flow. GINT - Groovy Integration Test Framework is ideal for that. I have thousands of tests done this way for my plugins and a few hundred of those are for JIRA workflow testing. For workflow testing, at example would be: Create an issue with various field values, progress it through a workflow step, and retrieve the issue to verify it has the correct values using the built-in automatic comparisons. Repeat through other workflow steps. It is a bit of an investment in time to implement some good tests that check the things you care about in your environment, but, once that is in place, it makes life a lot easier for configuration changes and upgrades.

0 votes
Nathon Fowlie June 4, 2014

Cool thx for the replies. I'm pretty new to Maven so setting up a dev profile & might be a bit above my current skill level. I'll have a play with GINT and see if it can do what I need.

Suggest an answer

Log in or Sign up to answer