Hello!
I’m trying to add a workflow validator to one of my transitions where the transition is blocked if a JQL query returns 0 results. Essentially, the requirement is to check that a Test Case linked to the issue, during that particular transition. We’re in the process of migrating off Zephyr Squad onto Zephyr Scale, so I can’t use the issue links functions. I also need to make the check for both Squad & Scale tests, since this workflow is common between all projects in our instance (some using Squad, some using Scale).
I’m new to groovy but my script isn’t returning any errors. However, the transition is going through, even if I don’t have tests linked. Initiaally I had this working in a Condition, but the users were getting confused why the transition is missing. Stakeholders would prefer a validator so we can show the error on transition. Here is the script I have so far, any advice is greatly appreciated!
def ScaleTests = Issues.count(‘key={issue.key} and issue in hasTestCoverage()’)
def SquadTests = Issue.count(‘key = {issue.key} and issueFunction in linkedIssuesOf(“issue type = \”Test\””)’)
if (ScaleTests <0 || SquadTests < 0)
{return false;
InvalidInputException error = new InvalidInputException();
error.addError(“Test case must be linked to issue”);
throw error;
}
return true