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