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

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

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.

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.

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
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,262 views 5 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you