@@ -11,12 +11,17 @@ import trr = require('../agent/testresultreader');
11
11
import cm = require( '../agent/common' ) ;
12
12
import ifm = require( '../agent/interfaces' ) ;
13
13
import testifm = require( 'vso-node-api/interfaces/TestInterfaces' ) ;
14
+ import tc = require( './lib/testcommand' ) ;
15
+ import rp = require( '../agent/commands/results.publish' ) ;
16
+ import tec = require( './lib/testExecutionContext' ) ;
17
+
18
+ var jobInf = require ( './lib/testJobInfo' ) ;
14
19
15
20
function resultFile ( filename : string ) {
16
21
return path . resolve ( __dirname , 'testresults' , filename ) ;
17
22
}
18
23
19
- describe ( 'PublisherTests' , function ( ) {
24
+ describe ( 'PublisherTests' , function ( ) {
20
25
const runContext : trp . TestRunContext = {
21
26
requestedFor : "userx" ,
22
27
buildId : "21" ,
@@ -43,6 +48,8 @@ describe('PublisherTests', function () {
43
48
const resultsFileNUnit2 = resultFile ( 'nunitresults.1.xml' ) ;
44
49
const resultsFileXUnit = resultFile ( 'xunitresults.xml' ) ;
45
50
const resultsFileXUnit2 = resultFile ( 'xunitresults.1.xml' ) ;
51
+ var junitFilePath = path . resolve ( __dirname , './testresults/junitresults1.xml' ) ;
52
+ var testExecutionContext ;
46
53
47
54
it ( 'results.publish : JUnit results file' , ( ) => {
48
55
const feedbackChannel = new fm . TestFeedbackChannel ( ) ;
@@ -60,15 +67,15 @@ describe('PublisherTests', function () {
60
67
assert ( feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
61
68
} ) ;
62
69
} ) ;
63
-
70
+
64
71
it ( 'results.publish : JUnit results file with a suite and no cases' , ( ) => {
65
72
const feedbackChannel = new fm . TestFeedbackChannel ( ) ;
66
73
const testRunPublisher = new trp . TestRunPublisher ( feedbackChannel , null , "teamProject" , runContext , readerJUnit ) ;
67
74
return testRunPublisher . publishTestRun ( resultsFileJUnitNoTestCases ) . then ( createdTestRun => {
68
75
assert ( feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
69
76
} ) ;
70
77
} ) ;
71
-
78
+
72
79
it ( 'results.publish : JUnit results file with no suites' , ( ) => {
73
80
const feedbackChannel = new fm . TestFeedbackChannel ( ) ;
74
81
const testRunPublisher = new trp . TestRunPublisher ( feedbackChannel , null , "teamProject" , runContext , readerJUnit ) ;
@@ -82,7 +89,7 @@ describe('PublisherTests', function () {
82
89
const feedbackChannel = new fm . TestFeedbackChannel ( ) ;
83
90
const testRunPublisher = new trp . TestRunPublisher ( feedbackChannel , null , "teamProject" , runContext , readerNUnit ) ;
84
91
85
- return testRunPublisher . publishTestRun ( resultsFileNUnit ) . then ( createdTestRun => {
92
+ return testRunPublisher . publishTestRun ( resultsFileNUnit ) . then ( createdTestRun => {
86
93
assert ( feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
87
94
} ) ;
88
95
} ) ;
@@ -95,7 +102,7 @@ describe('PublisherTests', function () {
95
102
assert ( feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
96
103
} ) ;
97
104
} ) ;
98
-
105
+
99
106
it ( 'results.publish : error handling for end test run' , ( ) => {
100
107
const feedbackChannel = new fm . TestFeedbackChannel ( ) ;
101
108
const testRunPublisher = new trp . TestRunPublisher ( feedbackChannel , null , "teamProject" , runContext , readerJUnit ) ;
@@ -107,26 +114,26 @@ describe('PublisherTests', function () {
107
114
108
115
// error handling/propagation from end test run
109
116
return testRunPublisher . endTestRun ( testRun . id , testRun . resultsFile )
110
- . then ( createdTestRun => assert ( false , 'ResultPublish Task did not fail as expected' ) )
111
- . catch ( err => {
112
- assert ( err . message == "Too bad - endTestRun failed" , 'ResultPublish Task error message does not match expected - ' + err . message ) ;
113
- } ) ;
117
+ . then ( createdTestRun => assert ( false , 'ResultPublish Task did not fail as expected' ) )
118
+ . catch ( err => {
119
+ assert ( err . message == "Too bad - endTestRun failed" , 'ResultPublish Task error message does not match expected - ' + err . message ) ;
120
+ } ) ;
114
121
} ) ;
115
122
116
123
it ( 'results.publish : error handling for reading results' , ( ) => {
117
124
const feedbackChannel = new fm . TestFeedbackChannel ( ) ;
118
125
const testRunPublisher = new trp . TestRunPublisher ( feedbackChannel , null , "teamProject" , runContext , readerJUnit ) ;
119
-
126
+
120
127
// error handling/propagation from parsing failures of junit/nunit files
121
128
var resultsFile = path . resolve ( __dirname , './testresults/junit_bad.xml' ) ;
122
129
return testRunPublisher . publishTestRun ( resultsFile )
123
- . then ( createdTestRun => {
124
- assert ( ! feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
125
- } )
126
- . catch ( err => {
127
- assert ( err . message == "Unmatched closing tag: XYZXYZuite\nLine: 13\nColumn: 16\nChar: >" ,
130
+ . then ( createdTestRun => {
131
+ assert ( ! feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
132
+ } )
133
+ . catch ( err => {
134
+ assert ( err . message == "Unmatched closing tag: XYZXYZuite\nLine: 13\nColumn: 16\nChar: >" ,
128
135
'ResultPublish Task Failed as expected! Details : ' + err . message ) ;
129
- } ) ;
136
+ } ) ;
130
137
} ) ;
131
138
132
139
it ( 'results.publish : JUnit reader sanity check without run title' , ( ) => {
@@ -318,7 +325,7 @@ describe('PublisherTests', function () {
318
325
assert ( feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
319
326
} ) ;
320
327
} )
321
-
328
+
322
329
it ( 'results.publish : JUnit results file with merge support with one invalid xml file' , ( ) => {
323
330
const feedbackChannel = new fm . TestFeedbackChannel ( ) ;
324
331
const testRunPublisher = new trp . TestRunPublisher ( feedbackChannel , null , "teamProject" , runContext , readerXUnit ) ;
@@ -327,4 +334,20 @@ describe('PublisherTests', function () {
327
334
assert ( feedbackChannel . jobsCompletedSuccessfully ( ) , 'ResultPublish Task Failed! Details : ' + feedbackChannel . getRecordsString ( ) ) ;
328
335
} ) ;
329
336
} )
337
+
338
+ it ( 'results.publish : Publish Test Results with old task compat' , ( ) => {
339
+ var properties : { [ name : string ] : string } = { "type" : "junit" , "platform" : "platform" , "config" : "config" , "runTitle" : "Test Title" , "publishRunAttachments" : "true" , "fileNumber" : "1" } ;
340
+ var message = junitFilePath ;
341
+ var command : cm . ITaskCommand = new tc . TestCommand ( null , properties , message ) ;
342
+ testExecutionContext = new tec . TestExecutionContext ( new jobInf . TestJobInfo ( { } ) ) ;
343
+ testExecutionContext . variables [ 'system.teamProject' ] = "teamProject" ;
344
+ var testResultsPublisher = new rp . ResultsPublishCommand ( testExecutionContext , command ) ;
345
+
346
+ testResultsPublisher . runCommandAsync ( ) . then ( function ( result ) {
347
+ assert ( testExecutionContext . service . jobsCompletedSuccessfully ( ) ) ;
348
+ } ,
349
+ function ( err ) {
350
+ assert ( false , 'Publish Test Results failed for old tasks: ' + testExecutionContext . service . getRecordsString ( ) )
351
+ } ) ;
352
+ } )
330
353
} ) ;
0 commit comments