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

UIScript to show percent complete vs percent passed


#1

I wrote a UIscript to do a custom calculation and show percent completed. Completed means the test passed or failed or marked Not Applicable (a custom status). It only works on the test run and test plan pages, not it reports or overviews however. But I thought I’d post it here for others to use.

name: Tweak Percentage Complete
description: Alters the summary for percent complete.
author: Rusty Howell
version: 1.0
includes: ^(runs|plans)/view
excludes: 

js:
$(document).ready(
	function() {
		var o = uiscripts.context.run;
		if (o == undefined)
		{
			o = uiscripts.context.plan;
		}		
                var blocked = o.blocked_count;
                var untested = o.untested_count;
                var failed = o.failed_count;
                var retest = o.retest_count;
                var passed = o.passed_count;
		var na = o.custom_status1_count; // Not Applicable
		var running = o.custom_status2_count; // Running
		var legacy = o.custom_status3_count; // Legacy

		var total = blocked + untested + failed + retest + passed + na + running + legacy;   // + not_applicable + running
		var finished = passed + failed + na;
		var p = 100 * finished / total;

		//alert("total count: " + total );

		document.getElementsByClassName("chart-pie-percent-title")[0].innerHTML = p.toFixed() + "%";
		document.getElementsByClassName("chart-pie-percent-description")[0].innerHTML = "complete";
	}
);

#2

Thanks for sharing this, Rusty!

Cheers,
Tobias


#3

Hi Gents,

I would like to sum, calc % & display my custom statuses, so I used this code as a basis, however, my values are returning a “NaN”.
Is there somthing I am missing in this code or should I keep my Custom Status field names the same as “out of the box”

name: Updated Test Run & Chart to add New Status
description: Updated Test Plans/Runs to include (5) other custom statuses
author: Eugene Dudley
version: 1.0
includes: ^(runs|plans)/view
excludes:

js:
$(document).ready(
function() {
var o = uiscripts.context.run;
if (o == undefined)
{
o = uiscripts.context.plan;
}
var blocked_num = o.blocked_count;
var untested_num = o.untested_count;
var failed_num = o.failed_count;
var retest_num = o.retest_count;
var passed_num = o.passed_count;

	var na_num   	        = parseInt(o.na_count);
	var passed_pqa_num = parseInt(o.passed_pqa_coun);
	var passed_pqo_num = parseInt(o.passed_pqo_count);
	var passed_qa1_num = parseInt( o.passed_qa1_count);
	var passed_ua_num  =  parseInt(o.passed_ua_count); 

	var total = blocked_num  + untested_num  + failed_num  + retest_num  + na_num  + passed_num  + passed_pqa_num  + passed_pqo_num  + passed_qa1_num  +            passed_ua_num ;    
	var allpassed = passed_num  + passed_pqa_num  + passed_pqo_num  + passed_qa1_num  + passed_ua_num ;
	var p = 100 * (allpassed / total);

	// alert("total count: " + total );
        // alert("allpassed: " + allpassed );
	 alert("total PQA: " + passed_pqa_num );
         alert("total N-A: " +na_num  );

	document.getElementsByClassName("chart-pie-percent-title")[0].innerHTML = p.toFixed() + "%";
	document.getElementsByClassName("chart-pie-percent-description")[0].innerHTML = "passed_env";
}

);