Skip to content

Commit 55908ae

Browse files
Added testresults client for TCM (#555)
* added testresults client * Updated package.json * updated package version to 12.1.0
1 parent edb8646 commit 55908ae

File tree

9 files changed

+5274
-1
lines changed

9 files changed

+5274
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ These clients are available:
7171
* TaskAgent
7272
* Task
7373
* Test
74+
* TestResults
7475
* Tfvc
7576
* Wiki
7677
* Work

api/TestResultsApi.ts

Lines changed: 5201 additions & 0 deletions
Large diffs are not rendered by default.

api/WebApi.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import securityrolesm = require('./SecurityRolesApi');
2121
import taskagentm = require('./TaskAgentApi');
2222
import taskm = require('./TaskApi');
2323
import testm = require('./TestApi');
24+
import testresultsm = require('./TestResultsApi');
2425
import tfvcm = require('./TfvcApi');
2526
import wikim = require('./WikiApi');
2627
import workm = require('./WorkApi');
@@ -317,6 +318,13 @@ export class WebApi {
317318
return new testm.TestApi(serverUrl, handlers, this.options);
318319
}
319320

321+
public async getTestResultsApi(serverUrl?: string, handlers?: VsoBaseInterfaces.IRequestHandler[]): Promise<testresultsm.ITestResultsApi> {
322+
// TODO: Load RESOURCE_AREA_ID correctly.
323+
serverUrl = await this._getResourceAreaUrl(serverUrl || this.serverUrl, "c83eaf52-edf3-4034-ae11-17d38f25404c");
324+
handlers = handlers || [this.authHandler];
325+
return new testresultsm.TestResultsApi(serverUrl, handlers, this.options);
326+
}
327+
320328
public async getTfvcApi(serverUrl?: string, handlers?: VsoBaseInterfaces.IRequestHandler[]): Promise<tfvcm.ITfvcApi> {
321329
// TODO: Load RESOURCE_AREA_ID correctly.
322330
serverUrl = await this._getResourceAreaUrl(serverUrl || this.serverUrl, "8aa40520-446d-40e6-89f6-9c9f9ce44c48");

api/interfaces/TestInterfaces.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,6 +3891,30 @@ export interface TestResultFailuresAnalysis {
38913891
newFailures?: TestFailureDetails;
38923892
}
38933893

3894+
/**
3895+
* The test failure type resource
3896+
*/
3897+
export interface TestResultFailureType {
3898+
/**
3899+
* ID of the test failure type
3900+
*/
3901+
id: number;
3902+
/**
3903+
* Name of the test failure type
3904+
*/
3905+
name: string;
3906+
}
3907+
3908+
/**
3909+
* The test failure type request model
3910+
*/
3911+
export interface TestResultFailureTypeRequestModel {
3912+
/**
3913+
* Name of the test failure type
3914+
*/
3915+
name: string;
3916+
}
3917+
38943918
/**
38953919
* Group by for results
38963920
*/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azure-devops-node-api",
33
"description": "Node client for Azure DevOps and TFS REST APIs",
4-
"version": "12.0.0",
4+
"version": "12.1.0",
55
"main": "./WebApi.js",
66
"types": "./WebApi.d.ts",
77
"scripts": {

samples/creation.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ export async function run() {
202202
console.log(`found ${runs.length} test runs`);
203203
}
204204

205+
/********** TestResults **********/
206+
printSectionStart('TestResults');
207+
const testResultsApi = await vstsCollectionLevel.getTestResultsApi();
208+
const testRuns: TestRun[] = await testResultsApi.getTestRuns(common.getProject());
209+
210+
if (testRuns) {
211+
console.log(`found ${testRuns.length} test runs`);
212+
}
213+
205214
/********** Tfvc **********/
206215
printSectionStart("Tfvc");
207216
const tfvcApi = await vstsCollectionLevel.getTfvcApi();

samples/samples.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"release",
1313
"task",
1414
"test",
15+
"testResults",
1516
"wiki",
1617
"work",
1718
"workItemTracking"

samples/testResults.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as common from './common';
2+
import * as nodeApi from 'azure-devops-node-api';
3+
4+
import * as BuildApi from 'azure-devops-node-api/BuildApi';
5+
import * as CoreApi from 'azure-devops-node-api/CoreApi';
6+
import * as TestResultsApi from 'azure-devops-node-api/TestResultsApi';
7+
import * as BuildInterfaces from 'azure-devops-node-api/interfaces/BuildInterfaces';
8+
import * as CoreInterfaces from 'azure-devops-node-api/interfaces/CoreInterfaces';
9+
import * as TestInterfaces from 'azure-devops-node-api/interfaces/TestInterfaces';
10+
11+
export async function run(createdProjectId: string) {
12+
const projectId: string = common.getProject();
13+
const webApi: nodeApi.WebApi = await common.getWebApi();
14+
const testResultsApiObject: TestResultsApi.ITestResultsApi = await webApi.getTestResultsApi();
15+
const coreApiObject: CoreApi.CoreApi = await webApi.getCoreApi();
16+
const project: CoreInterfaces.TeamProject = await coreApiObject.getProject(projectId);
17+
18+
common.banner('Testing Samples');
19+
20+
common.heading('Get test suite runs');
21+
const runs: TestInterfaces.TestRun[] = await testResultsApiObject.getTestRuns(projectId);
22+
console.log('Current Runs:', runs);
23+
24+
common.heading('Get code coverage');
25+
const buildApiObject: BuildApi.IBuildApi = await webApi.getBuildApi();
26+
const defs: BuildInterfaces.DefinitionReference[] = await buildApiObject.getDefinitions(projectId);
27+
console.log('Code coverage for build' + defs[0].id + ':', await testResultsApiObject.getCodeCoverageSummary(projectId, defs[0].id));
28+
}

samples/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"release.ts",
2020
"task.ts",
2121
"test.ts",
22+
"testResults.ts",
2223
"wiki.ts",
2324
"work.ts",
2425
"workItemTracking.ts"

0 commit comments

Comments
 (0)