Zephyr
Zephyr (Formerly Test Management for Jira) is a test management solution that integrates with Jira. ScriptRunner integrates with Zephyr, allowing you to automate and customize your tests, making them more accurate and efficient.
Zephyr integration allows you to:
- Add a workflow condition that prevents an issue transition.
- Add a workflow post function that creates a test case when an issue performs a particular transition.
- Create a calculated scripted field that aggregates data for an epic.
- Create listeners to run an action when a specific Zephyr event fires.
ScriptRunner does not integrate with Zephyr Essential due to product limitations.
Zephyr Event Listeners
There are currently three Zephyr events available for ScriptRunner:
- TestExecutionChangedEvent - Fires when a test execution is updated.
- TestCaseChangedEvent - Fires when a test case is updated.
- TestCycleChangedEvent - Fires when a test cycle is updated.
Create listeners to run scripts when these Zephyr events fire.
Workflow Examples
Workflow Condition that Prevents an Issue Transition
The below examples show two ways of preventing an issue transition via a workflow condition using ScriptRunner's scripted condition option. The first example uses a JQL function provided by Zephyr. The second example shows the same functionality, but this time using Zephyr's Java API. Using the Java API means that this example can be extended using additional logic.
JQL Query that Fails if the Issue has any Outstanding Non-passing Tests
For further details on additional JQL functions provided by Zephyr and how to use them, please see the Advanced Search with JQL Functions documentation.
Script that Fails if the Issue has any Outstanding Non-passing Tests
Workflow Post Function that Creates a Test Case
The below example shows how to use a scripted post function to create a new test case using details from the issue.
Once done, the below code creates a new test case with the issue's details every time the issue is transitioned with the post function's corresponding workflow transition.
Scripted Fields Examples
Scripted Field for Displaying the Percentage of Passing Tests
The below example shows the creation of a scripted field which is used to display the percentage of passing tests. The script either displays the percentage of passing tests for an issue (or 100% in the case of issues with no tests) or, for an epic, displays the percentage of passing tests across all issues within that epic.
Once you have added the scripted field, you should have the following scripted field configuration:
Notice that the Searcher is listed as being a Free Text Searcher. This is the default. However, in order to make our scripted field more versatile and in order to run issue searches such as Percentage Of Tests Passing < 50 we need to change this to a Number Searcher. Now your config should look like the one below.
Zephyr Event Listeners Examples
To view example scripts for each Zephyr event listener see the Creating Listeners in Scriptrunner for Zephyr Events documentation.