Created
March 21, 2019 15:01
-
-
Save DaHoC/f30dc0344a9be19b5a601cd9f5a0ad85 to your computer and use it in GitHub Desktop.
JUnit test reports (e.g. exported by Eclipse) overview of testsuite durations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>JUnit Test Report Pie Chart over test durations</title> | |
<meta content=""> | |
<style></style> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
// Load google charts | |
google.charts.load('current', {'packages':['corechart']}); | |
// google.charts.setOnLoadCallback(drawChart); | |
// Draw the chart and set the chart values | |
function drawChart(dataArr) { | |
var data = google.visualization.arrayToDataTable(dataArr); | |
// Optional; add a title and set the width and height of the chart | |
var options = {'title':'TestSuite durations'}; | |
// Display the chart inside the <div> element with id="piechart" | |
var chart = new google.visualization.PieChart(document.getElementById('piechart')); | |
chart.draw(data, options); | |
} | |
let zip = (a1, a2) => a1.map((x, i) => [x, a2[i]]); | |
</script> | |
</head> | |
<body> | |
<input class="box" id="fileselect" type="file"> | |
<div id="piechart" style="width: 100%; height: 100%"></div> | |
<script type="text/javascript"> | |
var sel = document.getElementById('fileselect'); | |
sel.onchange = function() { | |
var file = document.getElementById('fileselect').files[0] | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
var parser = new DOMParser(); | |
var xmlDoc = parser.parseFromString(e.target.result,"text/xml"); | |
var testSuitesArr = [...xmlDoc.getElementsByTagName("testsuite")]; | |
var names = testSuitesArr.map(element => element.getAttribute("name")); | |
var times = testSuitesArr.map(element => parseFloat(element.getAttribute("time"))); | |
names.unshift("TestSuiteName"); | |
times.unshift("ReqSec"); | |
var namesAndTimes = zip(names, times); | |
drawChart(namesAndTimes); | |
} | |
if (file) | |
reader.readAsText(file) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a proof-of-concept and still looks like "Kraut und Rüben"