diff --git a/src/Readme.txt b/src/Readme.txt index aadfe5db..770d1ba7 100644 --- a/src/Readme.txt +++ b/src/Readme.txt @@ -60,6 +60,7 @@ CHANGELOG 4.0.13.0 + * New: Issue #207: Highlighting of test methods by line coverage * Fix: Issue #212: Fixed name of SonarQube file 4.0.12.0 diff --git a/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs b/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs index f61537e6..ce8c4aea 100644 --- a/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs +++ b/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs @@ -220,7 +220,7 @@ public void TestMethods(IEnumerable testMethods, IEnumerable{2}", + "", coverage.HasValue ? coverageRounded.ToString() : "undefined", coverage.HasValue ? ReportResources.Coverage2 + " " + coverage.Value.ToString(CultureInfo.InvariantCulture) + "% - " : string.Empty, WebUtility.HtmlEncode(ReportResources.All)); @@ -239,7 +239,7 @@ public void TestMethods(IEnumerable testMethods, IEnumerable", + "
", coverage.HasValue ? coverageRounded.ToString() : "undefined", coverage.HasValue ? ReportResources.Coverage2 + " " + coverage.Value.ToString(CultureInfo.InvariantCulture) + "% - " : string.Empty, WebUtility.HtmlEncode(testMethod.Name), @@ -731,7 +731,10 @@ public void LineAnalysis(int fileIndex, LineAnalysis analysis) string lineVisitStatus = ConvertToCssClass(analysis.LineVisitStatus, false); - this.reportTextWriter.Write(" LineVisitStatus.NotCoverable ? "coverableline" : string.Empty, + WebUtility.HtmlEncode(GetTooltip(analysis))); this.reportTextWriter.Write( "'AllTestMethods': {{'VC': '{0}', 'LVS': '{1}'}}", diff --git a/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom-azurepipelines.css b/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom-azurepipelines.css index e4908697..7da6fcb7 100644 --- a/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom-azurepipelines.css +++ b/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom-azurepipelines.css @@ -12,7 +12,7 @@ a:hover { color: #000; text-decoration: underline; } .containerright { border-left: solid 1px #EAEAEA; display: table-cell; width: 340px; min-width: 340px; background-color: #fff; height: 100%; } .containerrightfixed { position: fixed; padding: 0 20px 20px 20px; width: 300px; overflow-y: auto; height: 100%; top: 0; bottom: 0; } .containerrightfixed h1 { background-color: rgba(248,248,248,1); } -.containerrightfixed label, .containerright a { white-space: nowrap; overflow: hidden; display: inline-block; max-width: 300px; text-overflow: ellipsis; } +.containerrightfixed label, .containerright a { white-space: nowrap; overflow: hidden; display: inline-block; width: 100%; max-width: 300px; text-overflow: ellipsis; } .containerright a { margin-bottom: 3px; } @media screen and (max-width:1200px){ diff --git a/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.css b/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.css index 8ad5b130..20ce46e1 100644 --- a/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.css +++ b/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.css @@ -12,7 +12,7 @@ a:hover { color: #000; text-decoration: none; } .containerright { border-left: solid 1px #6f6f6f; display: table-cell; width: 340px; min-width: 340px; background-color: #e5e5e5; height: 100%; } .containerrightfixed { position: fixed; padding: 0 20px 20px 20px; width: 300px; overflow-y: auto; height: 100%; top: 0; bottom: 0; } .containerrightfixed h1 { background-color: #c00; } -.containerrightfixed label, .containerright a { white-space: nowrap; overflow: hidden; display: inline-block; max-width: 300px; text-overflow: ellipsis; } +.containerrightfixed label, .containerright a { white-space: nowrap; overflow: hidden; display: inline-block; width: 100%; max-width: 300px; text-overflow: ellipsis; } .containerright a { margin-bottom: 3px; } @media screen and (max-width:1200px){ diff --git a/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.js b/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.js index 483326c2..a0afdc2c 100644 --- a/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.js +++ b/src/ReportGenerator.Core/Reporting/Builders/Rendering/resources/custom.js @@ -25,7 +25,7 @@ var switchTestMethod = function () { coverageData = JSON.parse(lines[i].getAttribute('data-coverage').replace(/'/g, '"')); lineAnalysis = coverageData[method]; cells = lines[i].querySelectorAll('td'); - if (lineAnalysis === null) { + if (lineAnalysis === undefined) { lineAnalysis = coverageData.AllTestMethods; if (lineAnalysis.LVS !== 'gray') { cells[0].setAttribute('class', 'red'); @@ -45,6 +45,32 @@ for (i = 0, l = testMethods.length; i < l; i++) { testMethods[i].addEventListener('change', switchTestMethod); } +/* Highlight test method by line */ +var highlightTestMethods = function () { + var lineAnalysis; + var coverageData = JSON.parse(this.getAttribute('data-coverage').replace(/'/g, '"')); + var testMethods = document.getElementsByClassName('testmethod'); + + for (i = 0, l = testMethods.length; i < l; i++) { + lineAnalysis = coverageData[testMethods[i].id]; + if (lineAnalysis === undefined) { + testMethods[i].className = testMethods[i].className.replace(/\s*light.+/g, ""); + } else { + testMethods[i].className += ' light' + lineAnalysis.LVS; + } + } +}; +var unhighlightTestMethods = function () { + var testMethods = document.getElementsByClassName('testmethod'); + for (i = 0, l = testMethods.length; i < l; i++) { + testMethods[i].className = testMethods[i].className.replace(/\s*light.+/g, ""); + } +}; +var coverableLines = document.getElementsByClassName('coverableline'); +for (i = 0, l = coverableLines.length; i < l; i++) { + coverableLines[i].addEventListener('mouseenter', highlightTestMethods); + coverableLines[i].addEventListener('mouseleave', unhighlightTestMethods); +} /* History charts */ var renderChart = function (chart) {