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+ }
0 commit comments