Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Customizing defect description template for push to JIRA


#1

Hi, how would I go about customizing the template for the description field when pushing a test case to a JIRA ticket.

I currently have the following in my integration settings for the template:
%tests:custom_step_results%
%tests:comment%
%tests:details%

which outputs in the following format when pushed to JIRA:

1. Test step details

Expected result for step

Status
2. Test step details

Expected result for step

Status
3. Test step details

Expected result for step

Status

Comments

Test Details

I am wondering how I would go about editing the %tests:custom_step_results% placeholder variable so that there is a space or horizontal line between each step and adding a heading for the expected result and status, so it looks like the format below:

1. Test step details

Expected Result: Text for expected result for step

Status: Status outcome

2. Test step details

Expected Result: Text for expected result for step

Status: Status outcome

3. Test step details

Expected Result: Text for expected result for step

Status: Status outcome

Comments

Test Details

This would just improve the readability of the description when it is pushed to JIRA.
There are actually many formatting options that can be used in the description field in JIRA, similar to this forum actually. Is it possible to define these options in TestRail’s description template? (eg. making tables, changing text format/styles etc)


#2

Hello Aygun,

Thanks for your posting! The rendering of the individual fields in the templates cannot be influenced currently (only the template itself). For JIRA, I can highly recommend looking into using our new JIRA add-on we recently introduced with TR 5.0 and this would display all case and result details directly in JIRA (in a structured way):

https://blog.gurock.com/?p=3365
http://docs.gurock.com/testrail-integration/tools-jira

The add-on is available for both JIRA Server and JIRA Cloud and provides a full two-way integration between JIRA and TestRail.

I hope this helps!

Cheers,
Tobias


#3

I have the same question, I just want to make something like and just click to push to JIRA and will see this

Tobias, could you help me, because it is very important for us

Thanks,
Nikita


#4

Hi Nikita,

Thank you for your post. In this case, are you referring to wanting to have the table automatically display in the description field automatically so you simply need to fill it in or are you wanting the table to already be filled in with the steps, expected results, actual results, and status?

Currently it is not directly possible to have the table included in TestRail Cloud however if you are running TestRail Server it is possible to customize the defect plugin further, which could be done to include this table automatically.

http://docs.gurock.com/testrail-integration/defects-plugins-examples


#5

Hi Marty,

We have a licensed TestRail Server and yes I want to get it automatically.

I didn’t find a class or function that can parse the %tests:custom_step_results% and provide us with the correct structure of description output.

In case now I used to %tests:custom_step_results%, but it gave me very simple structure of steps, results, etc
Like this:

3. Step number 3
---
result number 3
---
Unexpected behaviour
---
Failed
4. Step number 4
---
result number 4
---
Unexpected behaviour
---
Failed

So, I just want to improve this template or make some custom, but I didn’t find the function in your plugin.


#6

Guys, any updates?

The issue is not solved for me.

Thanks
Nikita


#7

Hi Nikita,

Thank you for your patience. In this case, you could configure the template being used for your integration by going to Administration > Integration.

Once here, click on the Enter a template link.

You would simply build your table in wiki markup so JIRA would recognize it.

Keep in mind that TestRail will not recognize wiki markup as TestRail uses markdown. This may be a little confusing to your users if they do not understand how to use wiki markup as well.


#8

Hello, thank you for you supporting

as you recommend, I guess, it’ll not fill automatically, it’ll just template for the user which can be used if he wants to push a bug. In my case, I want to fill it automatically.

now I use this settings

And I just want to change parsing %test:custom_step_results% template

Example:

3. Step number 3
---
result number 3
---
Unexpected behaviour
---
Failed

to

|3. Step number 3|result number 3|Unexpected behavior|Failed|

How can I do this?

Thanks,
Nikita


#9

Hi Nikita,

In this case, TestRail would automatically place the details the way you are seeing them under each other. You would not be able to have them show up side by side like you are wanting in this case.


#10

Done!
I’ll leave it here.

Make the next

and insert into the script application-combined.js code

var length_table = 5;
var stack = [];

var str = $('#defect_description').val();

for (var i=0;i < str.length;i++) {
    var char = str[i];
    
  if (stack.length == length_table*2) {
      break;
  }  
  if (char == '|') {
      stack.push(char);
  }  
}

var post_str = str.slice(i+1, str.length-1);
post_str = post_str.replace(/(\n---\n)+/g, '|');
post_str_list = post_str.split(/\n\d+\./g);
post_str_list = post_str_list.map(function (s, i) {
   var s_list = s.split('|');
   s_list = s_list.map(function(x) { return x.trim()});
   var last = s_list.pop();
   var one = s_list[0];
   if (i > 0){
      one = (++i + '. ' + one);  
   } 
   s_list[0] = one;
   if (last == 'Passed') {
           last = "{color:#008000}Passed{color}";
   } else if (last == 'Failed') {
           last = "{color:#ff0000}Failed{color}";
   }
   
   s_list.push(last);
   
   if (s_list.length == 3) {
           s = '|' + s_list[0] + '|' + s_list[1] + '| |' + s_list[2] + '|';
   } else if (s_list.length == 2) {
   s = '|' + s_list[0] + '| | |' + s_list[1] + '|';
   } else {
       s = '|' + s_list.join('|') + '|';
   }
   return s;
})

post_str = post_str_list.join('\n');
str = str.slice(0, i+1) + post_str;
$('#defect_description').val(str);

You will get


#11

Hey Nikita,

Thank you so much for posting this. This is really great and I am glad you were able to implement this based on our information and your trial. This will definitely help others on the forum!


#12

Hi, since i’m also interested in this solution, i was trying to modify the application-combined.js. But i need a little more information where to add the code.

Could you please help?

Thanks in advance!
Oliver


#13

@martylavender Can you provide help?
Thanks in advance!


#14

Hey Oliver,

Thank you for your post. We typically do not help with custom coding and this is something we would also recommend having working knowledge of programming for. Is there by chance someone in your group that is familiar with this?


#15

Hi Marty,

thanks for your reply. I’m familiar with programming and i looked into application-combined.js. But as you know it is a packed JavaScript file with one line and 54539 characters. Since this is clearly not that easy to look into, it would be a least a help to know in which function this should be added.
For example the string ‘#defect_description’ is no-where in the .js file.
At least a hint would be helpful.

Thanks!


#16

Hello,

We are trying to integrate and customize but I cannot find the .js file that you have mentioned. Can you help me on this, please? Also, we are using Cloud version.

Thanks
Peter


#17

I guees in cloud version you don’t have access to .js file.