January 28, 2020

5 ways to enhance traceability in TM4J with ScriptRunner

Sergejs Cuhrajs 3 minute read

If you run your tests inside Jira, one of the most critical things is traceability. That is to say, making sure your Jira issues (or requirements) are properly linked with your testing items, such as test cases or test executions. It can be a cumbersome, manual process, that can be easily forgotten when rushing to meet deadlines. 

In this post, we’ll share 5 ways how, thanks to the new integration with ScriptRunner, you can automate these small but essential day-to-day tasks in TM4J - Test Management for Jira, thus improving traceability and visibility of your testing processes across teams and stakeholders.

Sometimes it’s the small things that make the biggest impact 

The ScriptRunner and TM4J integration (currently available for Server/DC) consists of opportunities created by scripted fields and events/listeners. 

ScriptRunner's custom scripted fields allow you to configure Jira issues specifically for your needs to give you a better, more comprehensive view of your testing effort, without having to necessarily open TM4J every time to get that information. 

We also added three TM4J events in ScriptRunner listeners. When these TM4J events fire, ScriptRunner is able to hear the event (using the said ‘listeners’) and subsequently trigger a script to run. 

listeners setup

Below you'll find a selection of common TM4J scenarios along with links to specific scripts to enable them in ScriptRunner.

1# Keep Jira issues in sync with test cases

When a test case is updated, you may want to transition any linked Jira issues to the proper status so your team knows whether the requirement is covered or not. 


Get the script here


2# Keep Jira issues in sync with test cycles

When a test cycle is completed, for example, you may want to transition any linked Jira issues to the proper status so that other team members can know that testing is complete, and review/ action the results. 


Get the script here


3# Keep Jira issues in sync with test executions 

When a test execution is updated, you may want to transition any linked Jira issues/bugs to the proper status so your team knows which bugs are ready for retesting and which stories can be released.  


Get the script here


#4 Automatically update your team on the progress of testing 

Did you know that you can use listeners in ScriptRunner to trigger real-time updates via email or Slack notifications when a TM4J event occurs? For example, you can notify your test manager when a test case is ready for approval, or your team members can stay up-to-date when a test execution passes or fails. 

 Integration emailslack


Get the script here


#5 Have better visibility of linked test entities right inside Jira 

Using ScriptRunner's script fields, you can customise the TM4J data you see in Jira issues. The field values are calculated automatically by ScriptRunner and never need manual maintenance, ensuring what you see is an accurate reflection of your testing efforts. With the example script linked below, you can display how many test cases are linked to a given Jira issue so you can have a better visibility of your coverage.

test case visiblity


Get the script here


Sharing is caring

Once you’ve got the hang of it, you can start building on the above ScriptRunner scripts and create your own ways to automate various day-to-day tasks in TM4J. Wanna share your scripts with the Adaptavist Library community? Simply open a ticket with the code and a short description, and we’ll take it from there.

As we continue working on the integration, we want to hear from you - what tasks in TM4J would you want to automate using ScriptRunner? Let us know via email or in the comments below.

Now, let’s #GetTestingDone.