Skip to content

Commit 4073ed9

Browse files
committed
added support for deltas, updated logo
1 parent 08052fd commit 4073ed9

10 files changed

+119
-20
lines changed

README.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,61 @@
11
# Code Coverage Dashboard Widgets
2-
This repository contains a collection of [Azure DevOps](https://dev.azure.com) and Azure DevOps Server (Team Foundation Server) dashboard widgets that can be used to extract unit test code coverage metrics right into your dashboards.
2+
* NOTE: This works with Azure DevOps and Azure DevOps Server (Team Foundation Server). However, Microsoft requires TFS 2015 Update 3 or higher for folks using Azure DevOps Server (Team Foundation Server).
33

4-
NOTE: This works with Azure DevOps and Azure DevOps Server (Team Foundation Server). However, Microsoft requires TFS 2015 Update 3 or higher for folks using Team Foundation Server.
4+
## Code Coverage Widget
5+
This widget displays the percentage of unit test code coverage based on a selected build definition. If a build definition does not have any unit tests results recognized by the widget or if has not yet been configured, it will indicate so with a message displayed within the widget.
56

67
![](img/preview1.png)
78

89
The following configuration options are available:
910

1011
![](img/screenshots/configuration.png)
1112

13+
## Release Notes
14+
* 1.0.272
15+
* Added configuration option to display delta of previous build's coverage.
16+
* Updated logo and screenshots.
17+
* 1.0.219
18+
* Fixed issues where widget would not render properly.
19+
* 1.0.195
20+
* Added configuration option to display measurement name (via PR from [Tommy Vernieri](https://github.com/Blackbaud-TommyVernieri))
21+
* 1.0.194
22+
* Added support for Branches (via PR from [Tommy Vernieri](https://github.com/Blackbaud-TommyVernieri))
23+
* 1.0.191
24+
* Added support for Failed builds that produce code coverage results.
25+
* 1.0.190
26+
* Added support for Partially Succeeded builds.
27+
* 1.0.189
28+
* Updated to latest SDK.
29+
* Minor updates to improve error handling.
30+
* 1.0.171
31+
* Added configuration option to display up to two decimal places. Zero is the default.
32+
* Added broader configuration options for broader coverage measurement:
33+
* Blocks
34+
* Branch
35+
* Class
36+
* Complexity
37+
* Instruction
38+
* Line
39+
* Lines (this is the default)
40+
* Method
41+
* 1.0.166
42+
* Added configuration option to measure Lines or Blocks.
43+
* 1.0.162
44+
* Displayed build name now links to build details.
45+
* 1.0.149
46+
* Fixed defect where build was not showing as selected.
47+
* Added configuration option to display build name on widget.
48+
* Updated to match native style.
49+
* 1.0.122
50+
* Widget can now be resized to one or two columns in width.
51+
* 1.0.119
52+
* Build definitions are now sorted alphabetically.
53+
* 1.0.99
54+
* Initial release. Includes a single widget that extracts "Line" (.NET) or "Lines" (Java) code coverage results from unit tests executed during a build.
55+
56+
## Known Issues
57+
* Build definitions are limited to the first 1,000. This is a limitation of the Azure DevOps REST API.
58+
1259
## Contributing
1360
If you would like to contribute to these widgets, clone this repository and make your changes. Then submit
1461
a pull request and I'll review it as soon as possible.

code-coverage1.html

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
}
3838

3939
// Output diagnostics info to console
40-
console.log('projectId = ' + projectId);
41-
console.log('settings.buildDefinition = ' + settings.buildDefinition);
40+
console.log('settings.buildDefinition: ' + settings.buildDefinition);
4241

4342
if (parseInt(settings.buildDefinition) > 0) {
4443
// Get most recent successful build details
@@ -52,15 +51,15 @@
5251
var buildWeb = query2[0]._links.web.href
5352

5453
// Output diagnostics info to console
55-
console.log('buildId = ' + buildId);
54+
console.log('buildId: ' + buildId);
5655

5756
// Get code coverage summary for most recent build
5857
TFS_TestMgmt_WebApi.getClient().getCodeCoverageSummary(projectId, buildId)
5958
.then(function (query3) {
6059
// Evaluate for where there is no coverage data
6160
if (query3.coverageData[0]) {
6261
// Output diagnostics info to console
63-
console.log('coverageData found.');
62+
console.log('event: coverageData found');
6463
// Filter for selected coverage measurement
6564
var coverageMeasurement = "";
6665
if (!settings || !settings.coverageMeasurement) {
@@ -78,11 +77,18 @@
7877
var totalMeasurement = 0;
7978
var coveredMeasurement = 0;
8079
var coveragePct = 0;
80+
var deltaMeasurement = 0;
8181
$.each(coverageData, function(key, value) {
8282
totalMeasurement += value.total;
8383
coveredMeasurement += value.covered;
84+
deltaMeasurement += value.delta;
85+
// Output diagnostics info to console
86+
console.log('event: delta found');
8487
});
85-
88+
89+
// Output diagnostics info to console
90+
console.log('deltaMeasurement: ' + deltaMeasurement);
91+
8692
// Calculate code coverage percentage
8793
// This check avoids divide by zero error
8894
if (totalMeasurement > 0) {
@@ -109,6 +115,13 @@
109115
// Use the default percent label
110116
$("#percent-label").text("Percent");
111117
}
118+
var percentLabelString = $("#percent-label").text();
119+
120+
// Evaluate for delta display
121+
if (settings && settings.checkOptionDelta == true) {
122+
// Add the delta to the percent label
123+
$("#percent-label").text(percentLabelString + " (" + deltaMeasurement + "%)");
124+
}
112125

113126
$("div.big-count").text(coveragePct);
114127
$("div.big-count").show();
@@ -120,7 +133,7 @@
120133
}
121134
else {
122135
// Output diagnostics info to console
123-
console.log('No coverageData found.');
136+
console.log('event: no coverageData found');
124137
// Set display values for no coverage data
125138
$("div.big-count").hide();
126139
$("#percent-label").hide();
@@ -143,7 +156,7 @@
143156
});
144157
}
145158

146-
// Get a client to make REST calls to VSTS
159+
// Get a client to make REST calls
147160
return TFS_Build_WebApi.getClient().getDefinition(settings.buildDefinition, projectId)
148161
.then(function (query) {
149162
// Use the widget helper and return success as Widget Status
@@ -160,7 +173,7 @@
160173
$("h2.title").text(widgetSettings.name);
161174

162175
// Output diagnostics info to console
163-
console.log('event: load');
176+
console.log('event: load called');
164177

165178
return getBuildBuildInfo(widgetSettings);
166179
},
@@ -169,7 +182,7 @@
169182
$("h2.title").text(widgetSettings.name);
170183

171184
// Output diagnostics info to console
172-
console.log('event: reload');
185+
console.log('event: reload called');
173186

174187
return getBuildBuildInfo(widgetSettings);
175188
}

configuration.html

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
var $decimalPlacesDropdown = $("#decimal-places-dropdown");
2323
var $checkOptionBuildName = $("#check-option-build-name");
2424
var $checkOptionMeasurementName = $("#check-option-measurement-name");
25+
var $checkOptionDelta = $("#check-option-delta");
2526

2627
return {
2728
load: function (widgetSettings, widgetConfigurationContext) {
@@ -94,6 +95,15 @@
9495
$checkOptionMeasurementName.prop('checked', false);
9596
}
9697

98+
// If show delta has been previously selected, set the checkbox value
99+
if (settings && settings.checkOptionDelta == true) {
100+
$checkOptionDelta.prop('checked', true);
101+
}
102+
// Otherwise, mark the box as unchecked
103+
else {
104+
$checkOptionDelta.prop('checked', false);
105+
}
106+
97107
// If a build definition change has been made, prepare to persist the new values
98108
$buildDefinitionDropdown.on("change", function () {
99109
// Output diagnostics info to console
@@ -105,7 +115,8 @@
105115
coverageMeasurement: $coverageMeasurementDropdown.val(),
106116
decimalPlaces: $decimalPlacesDropdown.val(),
107117
checkOptionBuildName: $checkOptionBuildName.prop('checked'),
108-
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked')
118+
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked'),
119+
checkOptionDelta: $checkOptionDelta.prop('checked')
109120
})
110121
};
111122
var eventName = WidgetHelpers.WidgetEvent.ConfigurationChange;
@@ -124,7 +135,8 @@
124135
coverageMeasurement: $coverageMeasurementDropdown.val(),
125136
decimalPlaces: $decimalPlacesDropdown.val(),
126137
checkOptionBuildName: $checkOptionBuildName.prop('checked'),
127-
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked')
138+
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked'),
139+
checkOptionDelta: $checkOptionDelta.prop('checked')
128140
})
129141
};
130142
var eventName = WidgetHelpers.WidgetEvent.ConfigurationChange;
@@ -143,7 +155,8 @@
143155
coverageMeasurement: $coverageMeasurementDropdown.val(),
144156
decimalPlaces: $decimalPlacesDropdown.val(),
145157
checkOptionBuildName: $checkOptionBuildName.prop('checked'),
146-
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked')
158+
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked'),
159+
checkOptionDelta: $checkOptionDelta.prop('checked')
147160
})
148161
};
149162
var eventName = WidgetHelpers.WidgetEvent.ConfigurationChange;
@@ -162,7 +175,8 @@
162175
coverageMeasurement: $coverageMeasurementDropdown.val(),
163176
decimalPlaces: $decimalPlacesDropdown.val(),
164177
checkOptionBuildName: $checkOptionBuildName.prop('checked'),
165-
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked')
178+
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked'),
179+
checkOptionDelta: $checkOptionDelta.prop('checked')
166180

167181
})
168182
};
@@ -182,8 +196,28 @@
182196
coverageMeasurement: $coverageMeasurementDropdown.val(),
183197
decimalPlaces: $decimalPlacesDropdown.val(),
184198
checkOptionBuildName: $checkOptionBuildName.prop('checked'),
185-
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked')
199+
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked'),
200+
checkOptionDelta: $checkOptionDelta.prop('checked')
201+
})
202+
};
203+
var eventName = WidgetHelpers.WidgetEvent.ConfigurationChange;
204+
var eventArgs = WidgetHelpers.WidgetEvent.Args(customSettings);
205+
widgetConfigurationContext.notify(eventName, eventArgs);
206+
});
207+
208+
// If a show delta change has been made, prepare to persist the new values
209+
$checkOptionDelta.on("change", function () {
210+
// Output diagnostics info to console
211+
console.log('event: checkOptionDelta.change');
186212

213+
var customSettings = {
214+
data: JSON.stringify({
215+
buildDefinition: $buildDefinitionDropdown.val(),
216+
coverageMeasurement: $coverageMeasurementDropdown.val(),
217+
decimalPlaces: $decimalPlacesDropdown.val(),
218+
checkOptionBuildName: $checkOptionBuildName.prop('checked'),
219+
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked'),
220+
checkOptionDelta: $checkOptionDelta.prop('checked')
187221
})
188222
};
189223
var eventName = WidgetHelpers.WidgetEvent.ConfigurationChange;
@@ -204,8 +238,8 @@
204238
coverageMeasurement: $coverageMeasurementDropdown.val(),
205239
decimalPlaces: $decimalPlacesDropdown.val(),
206240
checkOptionBuildName: $checkOptionBuildName.prop('checked'),
207-
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked')
208-
241+
checkOptionMeasurementName: $checkOptionMeasurementName.prop('checked'),
242+
checkOptionDelta: $checkOptionDelta.prop('checked')
209243
})
210244
};
211245
return WidgetHelpers.WidgetConfigurationSave.Valid(customSettings);
@@ -260,6 +294,8 @@
260294
<label for="check-option-build-name">Show the name of the build</label><br/>
261295
<input type="checkbox" id="check-option-measurement-name" name="check-option-measurement-name">
262296
<label for="check-option-measurement-name">Show the name of the coverage measurement</label><br />
297+
<input type="checkbox" id="check-option-delta" name="check-option-delta">
298+
<label for="check-option-delta">Show the delta from previous build's coverage</label><br />
263299
</fieldset>
264300
</div>
265301
</div>

img/CatalogIcon.png

-8.76 KB
Loading

img/logo.png

-7.36 KB
Loading

img/preview1.png

16.4 KB
Loading

img/screenshots/configuration.png

-48.1 KB
Loading

img/screenshots/widgets.png

-16.3 KB
Loading

overview.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#Code Coverage Dashboard Widgets#
1+
#Code Coverage Dashboard Widgets
22
* NOTE: This works with Azure DevOps and Azure DevOps Server (Team Foundation Server). However, Microsoft requires TFS 2015 Update 3 or higher for folks using Azure DevOps Server (Team Foundation Server).
33

44
## Release Notes
5+
* 1.0.272
6+
* Added configuration option to display delta of previous build's coverage.
7+
* Updated logo and screenshots.
58
* 1.0.219
69
* Fixed issues where widget would not render properly.
710
* 1.0.195

vss-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifestVersion": 1,
33
"id": "code-coverage-dashboard-widgets",
4-
"version": "1.0.219",
4+
"version": "1.0.272",
55
"name": "Code Coverage Widgets",
66
"description": "A collection of dashboard widgets for displaying code coverage details in Azure DevOps.",
77
"publisher": "shanebdavis",

0 commit comments

Comments
 (0)