TestRestClient class

Base class that should be used (derived from) to make requests to VSS REST apis

Extends

Constructors

TestRestClient(IVssRestClientOptions)

Properties

RESOURCE_AREA_ID

Methods

addCustomFields(CustomTestFieldDefinition[], string)
addTestCasesToSuite(string, number, number, string)

Add test cases to suite.

addTestResultsToTestRun(TestCaseResult[], string, number)

Add test results to a test run.

addWorkItemToTestLinks(WorkItemToTestLinks, string)
createTestIterationResultAttachment(TestAttachmentRequestModel, string, number, number, number, string)

Attach a file to test step result

createTestResultAttachment(TestAttachmentRequestModel, string, number, number)

Attach a file to a test result.

createTestRun(RunCreateModel, string)

Create new test run.

createTestRunAttachment(TestAttachmentRequestModel, string, number)

Attach a file to a test run.

createTestSession(TestSession, TeamContext)

Create a test session

createTestSettings(TestSettings, string)
createTestSubResultAttachment(TestAttachmentRequestModel, string, number, number, number)

Attach a file to a test result

deleteSharedParameter(string, number)
deleteSharedStep(string, number)
deleteTestCase(string, number)

Delete a test case.

deleteTestMethodToWorkItemLink(string, string, number)
deleteTestRun(string, number)

Delete a test run by its ID.

deleteTestSettings(string, number)
getBugsLinkedToTestResult(string, number, number)
getBuildCodeCoverage(string, number, number)

Get code coverage data for a build.

getCodeCoverageSummary(string, number, number)

Get Code Coverage Summary for Build.

getLinkedWorkItemsByQuery(LinkedWorkItemsQuery, string)
getPoint(string, number, number, number, string)

Get a test point.

getPoints(string, number, number, string, string, string, string, boolean, number, number)

Get a list of test points.

getPointsByQuery(TestPointsQuery, string, number, number)

Get test points using query.

getResultGroupsByBuild(string, number, string, string[], string)
getResultGroupsByRelease(string, number, string, number, string[], string)
getResultRetentionSettings(string)

Get test result retention settings

getTestCaseById(string, number, number, number)

Get a specific test case in a test suite with test case id.

getTestCases(string, number, number)

Get all test cases in a suite.

getTestIteration(string, number, number, number, boolean)

Get iteration for a result

getTestIterations(string, number, number, boolean)

Get iterations for a result

getTestResultAttachmentContent(string, number, number, number)

Download a test result attachment by its ID.

getTestResultAttachments(string, number, number)

Get list of test result attachments reference.

getTestResultAttachmentZip(string, number, number, number)

Download a test result attachment by its ID.

getTestResultById(string, number, number, ResultDetails)

Get a test result for a test run.

getTestResultDetailsForBuild(string, number, string, string, string, string, boolean, boolean)
getTestResultDetailsForRelease(string, number, number, string, string, string, string, boolean, boolean)
getTestResults(string, number, ResultDetails, number, number, TestOutcome[])

Get test results for a test run.

getTestResultsByBuild(string, number, string, TestOutcome[], number, string)
getTestResultsByQuery(TestResultsQuery, string)

This API will return results by Ids with fields specified/trend for particular automated test method. We are still improving this API and have not finalized proper signature and contract.

getTestResultsByRelease(string, number, number, string, TestOutcome[], number, string)
getTestRunAttachmentContent(string, number, number)

Download a test run attachment by its ID.

getTestRunAttachments(string, number)

Get list of test run attachments reference.

getTestRunAttachmentZip(string, number, number)

Download a test run attachment by its ID.

getTestRunById(string, number, boolean)

Get a test run by its ID.

getTestRunCodeCoverage(string, number, number)

Get code coverage data for a test run

getTestRunLogs(string, number)

Get test run message logs

getTestRuns(string, string, string, string, number, boolean, boolean, number, number)

Get a list of test runs.

getTestRunStatistics(string, number)

Get test run statistics , used when we want to get summary of a run by outcome.

getTestSessions(TeamContext, number, boolean, boolean, TestSessionSource, boolean)

Get a list of test sessions

getTestSettingsById(string, number)
getTestSubResultAttachmentContent(string, number, number, number, number)

Download a test sub result attachment

getTestSubResultAttachments(string, number, number, number)

Get list of test sub result attachments

getTestSubResultAttachmentZip(string, number, number, number, number)

Download a test sub result attachment

publishTestResultDocument(TestResultDocument, string, number)
queryCustomFields(string, CustomTestFieldScope)
queryResultTrendForBuild(TestResultTrendFilter, string)
queryResultTrendForRelease(TestResultTrendFilter, string)
queryTestHistory(TestHistoryQuery, string)

Get history of a test method using TestHistoryQuery

queryTestMethodLinkedWorkItems(string, string)
queryTestResultHistory(ResultsFilter, string)
queryTestResultsMetaData(string[], string)

Get list of test Result meta data details for corresponding testcasereferenceId

queryTestResultsReportForBuild(string, number, string, boolean, BuildReference)
queryTestResultsReportForRelease(string, number, number, string, boolean, ReleaseReference)
queryTestResultsSummaryForReleases(ReleaseReference[], string)
queryTestResultWorkItems(string, string, string, number, Date, number, number)
queryTestRuns(string, Date, Date, TestRunState, number[], boolean, TestRunPublishContext, number[], number[], string, number[], number[], number[], number[], string, number, string)

Query Test Runs based on filters. Mandatory fields are minLastUpdatedDate and maxLastUpdatedDate.

queryTestSummaryByRequirement(TestResultsContext, string, number[])
removeTestCasesFromSuiteUrl(string, number, number, string)

The test points associated with the test cases are removed from the test suite. The test case work item is not deleted from the system. See test cases resource to delete a test case permanently.

updateCodeCoverageSummary(CodeCoverageData, string, number)

http://(tfsserver):8080/tfs/DefaultCollection/_apis/test/CodeCoverage?buildId=10 Request: Json of code coverage summary

updateResultRetentionSettings(ResultRetentionSettings, string)

Update test result retention settings

updateSuiteTestCases(SuiteTestCaseUpdateModel, string, number, number, string)

Updates the properties of the test case association in a suite.

updateTestPoints(PointUpdateModel, string, number, number, string)

Update test points.

updateTestResults(TestCaseResult[], string, number)

Update test results in a test run.

updateTestRun(RunUpdateModel, string, number)

Update test run by its ID.

updateTestSession(TestSession, TeamContext)

Update a test session

Constructor Details

TestRestClient(IVssRestClientOptions)

new TestRestClient(options: IVssRestClientOptions)

Parameters

Property Details

RESOURCE_AREA_ID

static RESOURCE_AREA_ID: string

Property Value

string

Method Details

addCustomFields(CustomTestFieldDefinition[], string)

function addCustomFields(newFields: CustomTestFieldDefinition[], project: string): Promise<CustomTestFieldDefinition[]>

Parameters

project

string

Project ID or project name

Returns

addTestCasesToSuite(string, number, number, string)

Add test cases to suite.

function addTestCasesToSuite(project: string, planId: number, suiteId: number, testCaseIds: string): Promise<SuiteTestCase[]>

Parameters

project

string

Project ID or project name

planId

number

ID of the test plan that contains the suite.

suiteId

number

ID of the test suite to which the test cases must be added.

testCaseIds

string

IDs of the test cases to add to the suite. Ids are specified in comma separated format.

Returns

Promise<SuiteTestCase[]>

addTestResultsToTestRun(TestCaseResult[], string, number)

Add test results to a test run.

function addTestResultsToTestRun(results: TestCaseResult[], project: string, runId: number): Promise<TestCaseResult[]>

Parameters

results

TestCaseResult[]

List of test results to add.

project

string

Project ID or project name

runId

number

Test run ID into which test results to add.

Returns

Promise<TestCaseResult[]>

function addWorkItemToTestLinks(workItemToTestLinks: WorkItemToTestLinks, project: string): Promise<WorkItemToTestLinks>

Parameters

workItemToTestLinks
WorkItemToTestLinks
project

string

Project ID or project name

Returns

createTestIterationResultAttachment(TestAttachmentRequestModel, string, number, number, number, string)

Attach a file to test step result

function createTestIterationResultAttachment(attachmentRequestModel: TestAttachmentRequestModel, project: string, runId: number, testCaseResultId: number, iterationId: number, actionPath?: string): Promise<TestAttachmentReference>

Parameters

attachmentRequestModel
TestAttachmentRequestModel

Attachment details TestAttachmentRequestModel

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test result that contains the iteration

iterationId

number

ID of the test result iteration.

actionPath

string

Hex value of test result action path.

Returns

createTestResultAttachment(TestAttachmentRequestModel, string, number, number)

Attach a file to a test result.

function createTestResultAttachment(attachmentRequestModel: TestAttachmentRequestModel, project: string, runId: number, testCaseResultId: number): Promise<TestAttachmentReference>

Parameters

attachmentRequestModel
TestAttachmentRequestModel

Attachment details TestAttachmentRequestModel

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test result against which attachment has to be uploaded.

Returns

createTestRun(RunCreateModel, string)

Create new test run.

function createTestRun(testRun: RunCreateModel, project: string): Promise<TestRun>

Parameters

testRun
RunCreateModel

Run details RunCreateModel

project

string

Project ID or project name

Returns

Promise<TestRun>

createTestRunAttachment(TestAttachmentRequestModel, string, number)

Attach a file to a test run.

function createTestRunAttachment(attachmentRequestModel: TestAttachmentRequestModel, project: string, runId: number): Promise<TestAttachmentReference>

Parameters

attachmentRequestModel
TestAttachmentRequestModel

Attachment details TestAttachmentRequestModel

project

string

Project ID or project name

runId

number

ID of the test run against which attachment has to be uploaded.

Returns

createTestSession(TestSession, TeamContext)

Create a test session

function createTestSession(testSession: TestSession, teamContext: TeamContext): Promise<TestSession>

Parameters

testSession
TestSession

Test session details for creation

teamContext
TeamContext

The team context for the operation

Returns

Promise<TestSession>

createTestSettings(TestSettings, string)

function createTestSettings(testSettings: TestSettings, project: string): Promise<number>

Parameters

testSettings
TestSettings
project

string

Project ID or project name

Returns

Promise<number>

createTestSubResultAttachment(TestAttachmentRequestModel, string, number, number, number)

Attach a file to a test result

function createTestSubResultAttachment(attachmentRequestModel: TestAttachmentRequestModel, project: string, runId: number, testCaseResultId: number, testSubResultId: number): Promise<TestAttachmentReference>

Parameters

attachmentRequestModel
TestAttachmentRequestModel

Attachment Request Model.

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test results that contains sub result.

testSubResultId

number

ID of the test sub results against which attachment has to be uploaded.

Returns

deleteSharedParameter(string, number)

function deleteSharedParameter(project: string, sharedParameterId: number): Promise<void>

Parameters

project

string

Project ID or project name

sharedParameterId

number

Returns

Promise<void>

deleteSharedStep(string, number)

function deleteSharedStep(project: string, sharedStepId: number): Promise<void>

Parameters

project

string

Project ID or project name

sharedStepId

number

Returns

Promise<void>

deleteTestCase(string, number)

Delete a test case.

function deleteTestCase(project: string, testCaseId: number): Promise<void>

Parameters

project

string

Project ID or project name

testCaseId

number

Id of test case to delete.

Returns

Promise<void>

function deleteTestMethodToWorkItemLink(project: string, testName: string, workItemId: number): Promise<boolean>

Parameters

project

string

Project ID or project name

testName

string

workItemId

number

Returns

Promise<boolean>

deleteTestRun(string, number)

Delete a test run by its ID.

function deleteTestRun(project: string, runId: number): Promise<void>

Parameters

project

string

Project ID or project name

runId

number

ID of the run to delete.

Returns

Promise<void>

deleteTestSettings(string, number)

function deleteTestSettings(project: string, testSettingsId: number): Promise<void>

Parameters

project

string

Project ID or project name

testSettingsId

number

Returns

Promise<void>

getBugsLinkedToTestResult(string, number, number)

function getBugsLinkedToTestResult(project: string, runId: number, testCaseResultId: number): Promise<WorkItemReference[]>

Parameters

project

string

Project ID or project name

runId

number

testCaseResultId

number

Returns

Promise<WorkItemReference[]>

getBuildCodeCoverage(string, number, number)

Get code coverage data for a build.

function getBuildCodeCoverage(project: string, buildId: number, flags: number): Promise<BuildCoverage[]>

Parameters

project

string

Project ID or project name

buildId

number

ID of the build for which code coverage data needs to be fetched.

flags

number

Value of flags determine the level of code coverage details to be fetched. Flags are additive. Expected Values are 1 for Modules, 2 for Functions, 4 for BlockData.

Returns

Promise<BuildCoverage[]>

getCodeCoverageSummary(string, number, number)

Get Code Coverage Summary for Build.

function getCodeCoverageSummary(project: string, buildId: number, deltaBuildId?: number): Promise<CodeCoverageSummary>

Parameters

project

string

Project ID or project name

buildId

number

ID of the build for which code coverage data needs to be fetched.

deltaBuildId

number

Delta Build id (optional)

Returns

getLinkedWorkItemsByQuery(LinkedWorkItemsQuery, string)

function getLinkedWorkItemsByQuery(workItemQuery: LinkedWorkItemsQuery, project: string): Promise<LinkedWorkItemsQueryResult[]>

Parameters

workItemQuery
LinkedWorkItemsQuery
project

string

Project ID or project name

Returns

getPoint(string, number, number, number, string)

Get a test point.

function getPoint(project: string, planId: number, suiteId: number, pointIds: number, witFields?: string): Promise<TestPoint>

Parameters

project

string

Project ID or project name

planId

number

ID of the test plan.

suiteId

number

ID of the suite that contains the point.

pointIds

number

ID of the test point to get.

witFields

string

Comma-separated list of work item field names.

Returns

Promise<TestPoint>

getPoints(string, number, number, string, string, string, string, boolean, number, number)

Get a list of test points.

function getPoints(project: string, planId: number, suiteId: number, witFields?: string, configurationId?: string, testCaseId?: string, testPointIds?: string, includePointDetails?: boolean, skip?: number, top?: number): Promise<TestPoint[]>

Parameters

project

string

Project ID or project name

planId

number

ID of the test plan.

suiteId

number

ID of the suite that contains the points.

witFields

string

Comma-separated list of work item field names.

configurationId

string

Get test points for specific configuration.

testCaseId

string

Get test points for a specific test case, valid when configurationId is not set.

testPointIds

string

Get test points for comma-separated list of test point IDs, valid only when configurationId and testCaseId are not set.

includePointDetails

boolean

Include all properties for the test point.

skip

number

Number of test points to skip..

top

number

Number of test points to return.

Returns

Promise<TestPoint[]>

getPointsByQuery(TestPointsQuery, string, number, number)

Get test points using query.

function getPointsByQuery(query: TestPointsQuery, project: string, skip?: number, top?: number): Promise<TestPointsQuery>

Parameters

query
TestPointsQuery

TestPointsQuery to get test points.

project

string

Project ID or project name

skip

number

Number of test points to skip..

top

number

Number of test points to return.

Returns

Promise<TestPointsQuery>

getResultGroupsByBuild(string, number, string, string[], string)

function getResultGroupsByBuild(project: string, buildId: number, publishContext: string, fields?: string[], continuationToken?: string): Promise<PagedList<FieldDetailsForTestResults>>

Parameters

project

string

Project ID or project name

buildId

number

publishContext

string

fields

string[]

continuationToken

string

Returns

getResultGroupsByRelease(string, number, string, number, string[], string)

function getResultGroupsByRelease(project: string, releaseId: number, publishContext: string, releaseEnvId?: number, fields?: string[], continuationToken?: string): Promise<PagedList<FieldDetailsForTestResults>>

Parameters

project

string

Project ID or project name

releaseId

number

publishContext

string

releaseEnvId

number

fields

string[]

continuationToken

string

Returns

getResultRetentionSettings(string)

Get test result retention settings

function getResultRetentionSettings(project: string): Promise<ResultRetentionSettings>

Parameters

project

string

Project ID or project name

Returns

getTestCaseById(string, number, number, number)

Get a specific test case in a test suite with test case id.

function getTestCaseById(project: string, planId: number, suiteId: number, testCaseIds: number): Promise<SuiteTestCase>

Parameters

project

string

Project ID or project name

planId

number

ID of the test plan that contains the suites.

suiteId

number

ID of the suite that contains the test case.

testCaseIds

number

ID of the test case to get.

Returns

Promise<SuiteTestCase>

getTestCases(string, number, number)

Get all test cases in a suite.

function getTestCases(project: string, planId: number, suiteId: number): Promise<SuiteTestCase[]>

Parameters

project

string

Project ID or project name

planId

number

ID of the test plan that contains the suites.

suiteId

number

ID of the suite to get.

Returns

Promise<SuiteTestCase[]>

getTestIteration(string, number, number, number, boolean)

Get iteration for a result

function getTestIteration(project: string, runId: number, testCaseResultId: number, iterationId: number, includeActionResults?: boolean): Promise<TestIterationDetailsModel>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test result that contains the iterations.

iterationId

number

Id of the test results Iteration.

includeActionResults

boolean

Include result details for each action performed in the test iteration. ActionResults refer to outcome (pass/fail) of test steps that are executed as part of a running a manual test. Including the ActionResults flag gets the outcome of test steps in the actionResults section and test parameters in the parameters section for each test iteration.

Returns

getTestIterations(string, number, number, boolean)

Get iterations for a result

function getTestIterations(project: string, runId: number, testCaseResultId: number, includeActionResults?: boolean): Promise<TestIterationDetailsModel[]>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test result that contains the iterations.

includeActionResults

boolean

Include result details for each action performed in the test iteration. ActionResults refer to outcome (pass/fail) of test steps that are executed as part of a running a manual test. Including the ActionResults flag gets the outcome of test steps in the actionResults section and test parameters in the parameters section for each test iteration.

Returns

getTestResultAttachmentContent(string, number, number, number)

Download a test result attachment by its ID.

function getTestResultAttachmentContent(project: string, runId: number, testCaseResultId: number, attachmentId: number): Promise<ArrayBuffer>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the testCaseResultId.

testCaseResultId

number

ID of the test result whose attachment has to be downloaded.

attachmentId

number

ID of the test result attachment to be downloaded.

Returns

Promise<ArrayBuffer>

getTestResultAttachments(string, number, number)

Get list of test result attachments reference.

function getTestResultAttachments(project: string, runId: number, testCaseResultId: number): Promise<TestAttachment[]>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test result.

Returns

Promise<TestAttachment[]>

getTestResultAttachmentZip(string, number, number, number)

Download a test result attachment by its ID.

function getTestResultAttachmentZip(project: string, runId: number, testCaseResultId: number, attachmentId: number): Promise<ArrayBuffer>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the testCaseResultId.

testCaseResultId

number

ID of the test result whose attachment has to be downloaded.

attachmentId

number

ID of the test result attachment to be downloaded.

Returns

Promise<ArrayBuffer>

getTestResultById(string, number, number, ResultDetails)

Get a test result for a test run.

function getTestResultById(project: string, runId: number, testCaseResultId: number, detailsToInclude?: ResultDetails): Promise<TestCaseResult>

Parameters

project

string

Project ID or project name

runId

number

Test run ID of a test result to fetch.

testCaseResultId

number

Test result ID.

detailsToInclude
ResultDetails

Details to include with test results. Default is None. Other values are Iterations, WorkItems and SubResults.

Returns

Promise<TestCaseResult>

getTestResultDetailsForBuild(string, number, string, string, string, string, boolean, boolean)

function getTestResultDetailsForBuild(project: string, buildId: number, publishContext?: string, groupBy?: string, filter?: string, orderby?: string, shouldIncludeResults?: boolean, queryRunSummaryForInProgress?: boolean): Promise<TestResultsDetails>

Parameters

project

string

Project ID or project name

buildId

number

publishContext

string

groupBy

string

filter

string

orderby

string

shouldIncludeResults

boolean

queryRunSummaryForInProgress

boolean

Returns

getTestResultDetailsForRelease(string, number, number, string, string, string, string, boolean, boolean)

function getTestResultDetailsForRelease(project: string, releaseId: number, releaseEnvId: number, publishContext?: string, groupBy?: string, filter?: string, orderby?: string, shouldIncludeResults?: boolean, queryRunSummaryForInProgress?: boolean): Promise<TestResultsDetails>

Parameters

project

string

Project ID or project name

releaseId

number

releaseEnvId

number

publishContext

string

groupBy

string

filter

string

orderby

string

shouldIncludeResults

boolean

queryRunSummaryForInProgress

boolean

Returns

getTestResults(string, number, ResultDetails, number, number, TestOutcome[])

Get test results for a test run.

function getTestResults(project: string, runId: number, detailsToInclude?: ResultDetails, skip?: number, top?: number, outcomes?: TestOutcome[]): Promise<TestCaseResult[]>

Parameters

project

string

Project ID or project name

runId

number

Test run ID of test results to fetch.

detailsToInclude
ResultDetails

Details to include with test results. Default is None. Other values are Iterations and WorkItems.

skip

number

Number of test results to skip from beginning.

top

number

Number of test results to return. Maximum is 1000 when detailsToInclude is None and 200 otherwise.

outcomes

TestOutcome[]

Comma separated list of test outcomes to filter test results.

Returns

Promise<TestCaseResult[]>

getTestResultsByBuild(string, number, string, TestOutcome[], number, string)

function getTestResultsByBuild(project: string, buildId: number, publishContext?: string, outcomes?: TestOutcome[], top?: number, continuationToken?: string): Promise<PagedList<ShallowTestCaseResult>>

Parameters

project

string

Project ID or project name

buildId

number

publishContext

string

outcomes

TestOutcome[]

top

number

continuationToken

string

Returns

getTestResultsByQuery(TestResultsQuery, string)

This API will return results by Ids with fields specified/trend for particular automated test method. We are still improving this API and have not finalized proper signature and contract.

function getTestResultsByQuery(query: TestResultsQuery, project: string): Promise<TestResultsQuery>

Parameters

project

string

Project ID or project name

Returns

Promise<TestResultsQuery>

getTestResultsByRelease(string, number, number, string, TestOutcome[], number, string)

function getTestResultsByRelease(project: string, releaseId: number, releaseEnvid?: number, publishContext?: string, outcomes?: TestOutcome[], top?: number, continuationToken?: string): Promise<PagedList<ShallowTestCaseResult>>

Parameters

project

string

Project ID or project name

releaseId

number

releaseEnvid

number

publishContext

string

outcomes

TestOutcome[]

top

number

continuationToken

string

Returns

getTestRunAttachmentContent(string, number, number)

Download a test run attachment by its ID.

function getTestRunAttachmentContent(project: string, runId: number, attachmentId: number): Promise<ArrayBuffer>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run whose attachment has to be downloaded.

attachmentId

number

ID of the test run attachment to be downloaded.

Returns

Promise<ArrayBuffer>

getTestRunAttachments(string, number)

Get list of test run attachments reference.

function getTestRunAttachments(project: string, runId: number): Promise<TestAttachment[]>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run.

Returns

Promise<TestAttachment[]>

getTestRunAttachmentZip(string, number, number)

Download a test run attachment by its ID.

function getTestRunAttachmentZip(project: string, runId: number, attachmentId: number): Promise<ArrayBuffer>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run whose attachment has to be downloaded.

attachmentId

number

ID of the test run attachment to be downloaded.

Returns

Promise<ArrayBuffer>

getTestRunById(string, number, boolean)

Get a test run by its ID.

function getTestRunById(project: string, runId: number, includeDetails?: boolean): Promise<TestRun>

Parameters

project

string

Project ID or project name

runId

number

ID of the run to get.

includeDetails

boolean

Default value is true. It includes details like run statistics, release, build, test environment, post process state, and more.

Returns

Promise<TestRun>

getTestRunCodeCoverage(string, number, number)

Get code coverage data for a test run

function getTestRunCodeCoverage(project: string, runId: number, flags: number): Promise<TestRunCoverage[]>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run for which code coverage data needs to be fetched.

flags

number

Value of flags determine the level of code coverage details to be fetched. Flags are additive. Expected Values are 1 for Modules, 2 for Functions, 4 for BlockData.

Returns

Promise<TestRunCoverage[]>

getTestRunLogs(string, number)

Get test run message logs

function getTestRunLogs(project: string, runId: number): Promise<TestMessageLogDetails[]>

Parameters

project

string

Project ID or project name

runId

number

ID of the run to get.

Returns

getTestRuns(string, string, string, string, number, boolean, boolean, number, number)

Get a list of test runs.

function getTestRuns(project: string, buildUri?: string, owner?: string, tmiRunId?: string, planId?: number, includeRunDetails?: boolean, automated?: boolean, skip?: number, top?: number): Promise<TestRun[]>

Parameters

project

string

Project ID or project name

buildUri

string

URI of the build that the runs used.

owner

string

Team foundation ID of the owner of the runs.

tmiRunId

string

planId

number

ID of the test plan that the runs are a part of.

includeRunDetails

boolean

If true, include all the properties of the runs.

automated

boolean

If true, only returns automated runs.

skip

number

Number of test runs to skip.

top

number

Number of test runs to return.

Returns

Promise<TestRun[]>

getTestRunStatistics(string, number)

Get test run statistics , used when we want to get summary of a run by outcome.

function getTestRunStatistics(project: string, runId: number): Promise<TestRunStatistic>

Parameters

project

string

Project ID or project name

runId

number

ID of the run to get.

Returns

Promise<TestRunStatistic>

getTestSessions(TeamContext, number, boolean, boolean, TestSessionSource, boolean)

Get a list of test sessions

function getTestSessions(teamContext: TeamContext, period?: number, allSessions?: boolean, includeAllProperties?: boolean, source?: TestSessionSource, includeOnlyCompletedSessions?: boolean): Promise<TestSession[]>

Parameters

teamContext
TeamContext

The team context for the operation

period

number

Period in days from now, for which test sessions are fetched.

allSessions

boolean

If false, returns test sessions for current user. Otherwise, it returns test sessions for all users

includeAllProperties

boolean

If true, it returns all properties of the test sessions. Otherwise, it returns the skinny version.

source
TestSessionSource

Source of the test session.

includeOnlyCompletedSessions

boolean

If true, it returns test sessions in completed state. Otherwise, it returns test sessions for all states

Returns

Promise<TestSession[]>

getTestSettingsById(string, number)

function getTestSettingsById(project: string, testSettingsId: number): Promise<TestSettings>

Parameters

project

string

Project ID or project name

testSettingsId

number

Returns

Promise<TestSettings>

getTestSubResultAttachmentContent(string, number, number, number, number)

Download a test sub result attachment

function getTestSubResultAttachmentContent(project: string, runId: number, testCaseResultId: number, attachmentId: number, testSubResultId: number): Promise<ArrayBuffer>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test results that contains sub result.

attachmentId

number

ID of the test result attachment to be downloaded

testSubResultId

number

ID of the test sub result whose attachment has to be downloaded

Returns

Promise<ArrayBuffer>

getTestSubResultAttachments(string, number, number, number)

Get list of test sub result attachments

function getTestSubResultAttachments(project: string, runId: number, testCaseResultId: number, testSubResultId: number): Promise<TestAttachment[]>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test results that contains sub result.

testSubResultId

number

ID of the test sub result whose attachment has to be downloaded

Returns

Promise<TestAttachment[]>

getTestSubResultAttachmentZip(string, number, number, number, number)

Download a test sub result attachment

function getTestSubResultAttachmentZip(project: string, runId: number, testCaseResultId: number, attachmentId: number, testSubResultId: number): Promise<ArrayBuffer>

Parameters

project

string

Project ID or project name

runId

number

ID of the test run that contains the result.

testCaseResultId

number

ID of the test results that contains sub result.

attachmentId

number

ID of the test result attachment to be downloaded

testSubResultId

number

ID of the test sub result whose attachment has to be downloaded

Returns

Promise<ArrayBuffer>

publishTestResultDocument(TestResultDocument, string, number)

function publishTestResultDocument(document: TestResultDocument, project: string, runId: number): Promise<TestResultDocument>

Parameters

project

string

Project ID or project name

runId

number

Returns

queryCustomFields(string, CustomTestFieldScope)

function queryCustomFields(project: string, scopeFilter: CustomTestFieldScope): Promise<CustomTestFieldDefinition[]>

Parameters

project

string

Project ID or project name

scopeFilter
CustomTestFieldScope

Returns

queryResultTrendForBuild(TestResultTrendFilter, string)

function queryResultTrendForBuild(filter: TestResultTrendFilter, project: string): Promise<AggregatedDataForResultTrend[]>

Parameters

project

string

Project ID or project name

Returns

queryResultTrendForRelease(TestResultTrendFilter, string)

function queryResultTrendForRelease(filter: TestResultTrendFilter, project: string): Promise<AggregatedDataForResultTrend[]>

Parameters

project

string

Project ID or project name

Returns

queryTestHistory(TestHistoryQuery, string)

Get history of a test method using TestHistoryQuery

function queryTestHistory(filter: TestHistoryQuery, project: string): Promise<TestHistoryQuery>

Parameters

filter
TestHistoryQuery

TestHistoryQuery to get history

project

string

Project ID or project name

Returns

Promise<TestHistoryQuery>

queryTestMethodLinkedWorkItems(string, string)

function queryTestMethodLinkedWorkItems(project: string, testName: string): Promise<TestToWorkItemLinks>

Parameters

project

string

Project ID or project name

testName

string

Returns

queryTestResultHistory(ResultsFilter, string)

function queryTestResultHistory(filter: ResultsFilter, project: string): Promise<TestResultHistory>

Parameters

filter
ResultsFilter
project

string

Project ID or project name

Returns

queryTestResultsMetaData(string[], string)

Get list of test Result meta data details for corresponding testcasereferenceId

function queryTestResultsMetaData(testReferenceIds: string[], project: string): Promise<TestResultMetaData[]>

Parameters

testReferenceIds

string[]

TestCaseReference Ids of the test Result to be queried, comma separated list of valid ids (limit no. of ids 200).

project

string

Project ID or project name

Returns

Promise<TestResultMetaData[]>

queryTestResultsReportForBuild(string, number, string, boolean, BuildReference)

function queryTestResultsReportForBuild(project: string, buildId: number, publishContext?: string, includeFailureDetails?: boolean, buildToCompare?: BuildReference): Promise<TestResultSummary>

Parameters

project

string

Project ID or project name

buildId

number

publishContext

string

includeFailureDetails

boolean

buildToCompare
BuildReference

Returns

queryTestResultsReportForRelease(string, number, number, string, boolean, ReleaseReference)

function queryTestResultsReportForRelease(project: string, releaseId: number, releaseEnvId: number, publishContext?: string, includeFailureDetails?: boolean, releaseToCompare?: ReleaseReference): Promise<TestResultSummary>

Parameters

project

string

Project ID or project name

releaseId

number

releaseEnvId

number

publishContext

string

includeFailureDetails

boolean

releaseToCompare
ReleaseReference

Returns

queryTestResultsSummaryForReleases(ReleaseReference[], string)

function queryTestResultsSummaryForReleases(releases: ReleaseReference[], project: string): Promise<TestResultSummary[]>

Parameters

releases

ReleaseReference[]

project

string

Project ID or project name

Returns

Promise<TestResultSummary[]>

queryTestResultWorkItems(string, string, string, number, Date, number, number)

function queryTestResultWorkItems(project: string, workItemCategory: string, automatedTestName?: string, testCaseId?: number, maxCompleteDate?: Date, days?: number, workItemCount?: number): Promise<WorkItemReference[]>

Parameters

project

string

Project ID or project name

workItemCategory

string

automatedTestName

string

testCaseId

number

maxCompleteDate

Date

days

number

workItemCount

number

Returns

Promise<WorkItemReference[]>

queryTestRuns(string, Date, Date, TestRunState, number[], boolean, TestRunPublishContext, number[], number[], string, number[], number[], number[], number[], string, number, string)

Query Test Runs based on filters. Mandatory fields are minLastUpdatedDate and maxLastUpdatedDate.

function queryTestRuns(project: string, minLastUpdatedDate: Date, maxLastUpdatedDate: Date, state?: TestRunState, planIds?: number[], isAutomated?: boolean, publishContext?: TestRunPublishContext, buildIds?: number[], buildDefIds?: number[], branchName?: string, releaseIds?: number[], releaseDefIds?: number[], releaseEnvIds?: number[], releaseEnvDefIds?: number[], runTitle?: string, top?: number, continuationToken?: string): Promise<PagedList<TestRun>>

Parameters

project

string

Project ID or project name

minLastUpdatedDate

Date

Minimum Last Modified Date of run to be queried (Mandatory).

maxLastUpdatedDate

Date

Maximum Last Modified Date of run to be queried (Mandatory, difference between min and max date can be atmost 7 days).

state
TestRunState

Current state of the Runs to be queried.

planIds

number[]

Plan Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10).

isAutomated

boolean

Automation type of the Runs to be queried.

publishContext
TestRunPublishContext

PublishContext of the Runs to be queried.

buildIds

number[]

Build Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10).

buildDefIds

number[]

Build Definition Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10).

branchName

string

Source Branch name of the Runs to be queried.

releaseIds

number[]

Release Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10).

releaseDefIds

number[]

Release Definition Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10).

releaseEnvIds

number[]

Release Environment Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10).

releaseEnvDefIds

number[]

Release Environment Definition Ids of the Runs to be queried, comma separated list of valid ids (limit no. of ids 10).

runTitle

string

Run Title of the Runs to be queried.

top

number

Number of runs to be queried. Limit is 100

continuationToken

string

continuationToken received from previous batch or null for first batch. It is not supposed to be created (or altered, if received from last batch) by user.

Returns

Promise<PagedList<TestRun>>

queryTestSummaryByRequirement(TestResultsContext, string, number[])

function queryTestSummaryByRequirement(resultsContext: TestResultsContext, project: string, workItemIds?: number[]): Promise<TestSummaryForWorkItem[]>

Parameters

resultsContext
TestResultsContext
project

string

Project ID or project name

workItemIds

number[]

Returns

removeTestCasesFromSuiteUrl(string, number, number, string)

The test points associated with the test cases are removed from the test suite. The test case work item is not deleted from the system. See test cases resource to delete a test case permanently.

function removeTestCasesFromSuiteUrl(project: string, planId: number, suiteId: number, testCaseIds: string): Promise<void>

Parameters

project

string

Project ID or project name

planId

number

ID of the test plan that contains the suite.

suiteId

number

ID of the suite to get.

testCaseIds

string

IDs of the test cases to remove from the suite.

Returns

Promise<void>

updateCodeCoverageSummary(CodeCoverageData, string, number)

http://(tfsserver):8080/tfs/DefaultCollection/_apis/test/CodeCoverage?buildId=10 Request: Json of code coverage summary

function updateCodeCoverageSummary(coverageData: CodeCoverageData, project: string, buildId: number): Promise<void>

Parameters

coverageData
CodeCoverageData
project

string

Project ID or project name

buildId

number

Returns

Promise<void>

updateResultRetentionSettings(ResultRetentionSettings, string)

Update test result retention settings

function updateResultRetentionSettings(retentionSettings: ResultRetentionSettings, project: string): Promise<ResultRetentionSettings>

Parameters

retentionSettings
ResultRetentionSettings

Test result retention settings details to be updated

project

string

Project ID or project name

Returns

updateSuiteTestCases(SuiteTestCaseUpdateModel, string, number, number, string)

Updates the properties of the test case association in a suite.

function updateSuiteTestCases(suiteTestCaseUpdateModel: SuiteTestCaseUpdateModel, project: string, planId: number, suiteId: number, testCaseIds: string): Promise<SuiteTestCase[]>

Parameters

suiteTestCaseUpdateModel
SuiteTestCaseUpdateModel

Model for updation of the properties of test case suite association.

project

string

Project ID or project name

planId

number

ID of the test plan that contains the suite.

suiteId

number

ID of the test suite to which the test cases must be added.

testCaseIds

string

IDs of the test cases to add to the suite. Ids are specified in comma separated format.

Returns

Promise<SuiteTestCase[]>

updateTestPoints(PointUpdateModel, string, number, number, string)

Update test points.

function updateTestPoints(pointUpdateModel: PointUpdateModel, project: string, planId: number, suiteId: number, pointIds: string): Promise<TestPoint[]>

Parameters

pointUpdateModel
PointUpdateModel

Data to update.

project

string

Project ID or project name

planId

number

ID of the test plan.

suiteId

number

ID of the suite that contains the points.

pointIds

string

ID of the test point to get. Use a comma-separated list of IDs to update multiple test points.

Returns

Promise<TestPoint[]>

updateTestResults(TestCaseResult[], string, number)

Update test results in a test run.

function updateTestResults(results: TestCaseResult[], project: string, runId: number): Promise<TestCaseResult[]>

Parameters

results

TestCaseResult[]

List of test results to update.

project

string

Project ID or project name

runId

number

Test run ID whose test results to update.

Returns

Promise<TestCaseResult[]>

updateTestRun(RunUpdateModel, string, number)

Update test run by its ID.

function updateTestRun(runUpdateModel: RunUpdateModel, project: string, runId: number): Promise<TestRun>

Parameters

runUpdateModel
RunUpdateModel

Run details RunUpdateModel

project

string

Project ID or project name

runId

number

ID of the run to update.

Returns

Promise<TestRun>

updateTestSession(TestSession, TeamContext)

Update a test session

function updateTestSession(testSession: TestSession, teamContext: TeamContext): Promise<TestSession>

Parameters

testSession
TestSession

Test session details for update

teamContext
TeamContext

The team context for the operation

Returns

Promise<TestSession>