Skip to content

Commit

Permalink
Added testresults client for TCM (#555)
Browse files Browse the repository at this point in the history
* added testresults client

* Updated package.json

* updated package version to 12.1.0
  • Loading branch information
triptijain2112 authored Jun 20, 2023
1 parent edb8646 commit 55908ae
Show file tree
Hide file tree
Showing 9 changed files with 5,274 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ These clients are available:
* TaskAgent
* Task
* Test
* TestResults
* Tfvc
* Wiki
* Work
Expand Down
5,201 changes: 5,201 additions & 0 deletions api/TestResultsApi.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions api/WebApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import securityrolesm = require('./SecurityRolesApi');
import taskagentm = require('./TaskAgentApi');
import taskm = require('./TaskApi');
import testm = require('./TestApi');
import testresultsm = require('./TestResultsApi');
import tfvcm = require('./TfvcApi');
import wikim = require('./WikiApi');
import workm = require('./WorkApi');
Expand Down Expand Up @@ -317,6 +318,13 @@ export class WebApi {
return new testm.TestApi(serverUrl, handlers, this.options);
}

public async getTestResultsApi(serverUrl?: string, handlers?: VsoBaseInterfaces.IRequestHandler[]): Promise<testresultsm.ITestResultsApi> {
// TODO: Load RESOURCE_AREA_ID correctly.
serverUrl = await this._getResourceAreaUrl(serverUrl || this.serverUrl, "c83eaf52-edf3-4034-ae11-17d38f25404c");
handlers = handlers || [this.authHandler];
return new testresultsm.TestResultsApi(serverUrl, handlers, this.options);
}

public async getTfvcApi(serverUrl?: string, handlers?: VsoBaseInterfaces.IRequestHandler[]): Promise<tfvcm.ITfvcApi> {
// TODO: Load RESOURCE_AREA_ID correctly.
serverUrl = await this._getResourceAreaUrl(serverUrl || this.serverUrl, "8aa40520-446d-40e6-89f6-9c9f9ce44c48");
Expand Down
24 changes: 24 additions & 0 deletions api/interfaces/TestInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3891,6 +3891,30 @@ export interface TestResultFailuresAnalysis {
newFailures?: TestFailureDetails;
}

/**
* The test failure type resource
*/
export interface TestResultFailureType {
/**
* ID of the test failure type
*/
id: number;
/**
* Name of the test failure type
*/
name: string;
}

/**
* The test failure type request model
*/
export interface TestResultFailureTypeRequestModel {
/**
* Name of the test failure type
*/
name: string;
}

/**
* Group by for results
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "azure-devops-node-api",
"description": "Node client for Azure DevOps and TFS REST APIs",
"version": "12.0.0",
"version": "12.1.0",
"main": "./WebApi.js",
"types": "./WebApi.d.ts",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions samples/creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ export async function run() {
console.log(`found ${runs.length} test runs`);
}

/********** TestResults **********/
printSectionStart('TestResults');
const testResultsApi = await vstsCollectionLevel.getTestResultsApi();
const testRuns: TestRun[] = await testResultsApi.getTestRuns(common.getProject());

if (testRuns) {
console.log(`found ${testRuns.length} test runs`);
}

/********** Tfvc **********/
printSectionStart("Tfvc");
const tfvcApi = await vstsCollectionLevel.getTfvcApi();
Expand Down
1 change: 1 addition & 0 deletions samples/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"release",
"task",
"test",
"testResults",
"wiki",
"work",
"workItemTracking"
Expand Down
28 changes: 28 additions & 0 deletions samples/testResults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as common from './common';
import * as nodeApi from 'azure-devops-node-api';

import * as BuildApi from 'azure-devops-node-api/BuildApi';
import * as CoreApi from 'azure-devops-node-api/CoreApi';
import * as TestResultsApi from 'azure-devops-node-api/TestResultsApi';
import * as BuildInterfaces from 'azure-devops-node-api/interfaces/BuildInterfaces';
import * as CoreInterfaces from 'azure-devops-node-api/interfaces/CoreInterfaces';
import * as TestInterfaces from 'azure-devops-node-api/interfaces/TestInterfaces';

export async function run(createdProjectId: string) {
const projectId: string = common.getProject();
const webApi: nodeApi.WebApi = await common.getWebApi();
const testResultsApiObject: TestResultsApi.ITestResultsApi = await webApi.getTestResultsApi();
const coreApiObject: CoreApi.CoreApi = await webApi.getCoreApi();
const project: CoreInterfaces.TeamProject = await coreApiObject.getProject(projectId);

common.banner('Testing Samples');

common.heading('Get test suite runs');
const runs: TestInterfaces.TestRun[] = await testResultsApiObject.getTestRuns(projectId);
console.log('Current Runs:', runs);

common.heading('Get code coverage');
const buildApiObject: BuildApi.IBuildApi = await webApi.getBuildApi();
const defs: BuildInterfaces.DefinitionReference[] = await buildApiObject.getDefinitions(projectId);
console.log('Code coverage for build' + defs[0].id + ':', await testResultsApiObject.getCodeCoverageSummary(projectId, defs[0].id));
}
1 change: 1 addition & 0 deletions samples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"release.ts",
"task.ts",
"test.ts",
"testResults.ts",
"wiki.ts",
"work.ts",
"workItemTracking.ts"
Expand Down

0 comments on commit 55908ae

Please sign in to comment.