Skip to content

Commit b4dcf77

Browse files
Fix problem running XUnit test for Full Framework, old style projects
1 parent 16a87e9 commit b4dcf77

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/fsharp/VSTestRunner.fs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,22 +225,29 @@ let getNUnitResults () =
225225
"alwaysArray" ==> true
226226
]
227227
let rec collectTestCases o =
228+
228229
let current = if !!o?``test-case`` <> Utils.undefined then unbox<obj[]>(o?``test-case``) else [||]
230+
let results = if !!o?``results`` <> Utils.undefined then unbox<obj[]>(o?``results``) else [||]
229231
let testSuites = if !!o?``test-suite`` <> Utils.undefined then unbox<obj[]>(o?``test-suite``) else [||]
230-
Array.append current (testSuites |> Array.collect collectTestCases)
232+
let suites = Array.append results testSuites
233+
Array.append current (suites |> Array.collect collectTestCases)
231234

232235
let res = convert?xml2js(xmlCnt, opts)
233-
let res = unbox<obj[]>(res?``test-run``).[0]
236+
let res =
237+
try
238+
unbox<obj[]>(res?``test-run``).[0]
239+
with
240+
| _ -> unbox<obj[]>(res?``test-results``).[0]
234241
collectTestCases res
235242

236243
let nUnitOldResultToTestResult obj =
237-
let name = !!obj?_attributes?fullname
238-
let timer = !!obj?_attributes?duration
244+
let name = if !!obj?_attributes?fullname <> undefined then !!obj?_attributes?fullname else !!obj?_attributes?name
245+
let timer = if !!obj?_attributes?duration <> undefined then !!obj?_attributes?duration else !!obj?_attributes?time
239246
let result = !!obj?_attributes?result
240247
let state =
241248
match result with
242-
| "Passed" -> TestState.Passed
243-
| "Failed" | "Inconclusive" -> TestState.Failed
249+
| "Passed" | "Success" -> TestState.Passed
250+
| "Failed" | "Failure" | "Inconclusive" -> TestState.Failed
244251
| "Skipped" -> TestState.Ignored
245252
| _ -> TestState.NotRun
246253
let error =
@@ -255,14 +262,16 @@ let nUnitOldResultToTestResult obj =
255262
let log = createConfiguredLoggers "NEPTUNE" "Neptune (F# - Classic Runners Adapter)"
256263

257264
let runAllTestsWithOldRunner (proj: Project) initial =
265+
258266
match findOldRunner proj with
259267
| None -> Promise.lift initial
260268
| Some (isNUnit, runner) ->
261269
let args =
262270
if isNUnit then "\"" + proj.Output + "\""
263271
else
272+
let p = Path.join(workspace.rootPath, "TestResult.xml")
264273
"\"" + proj.Output + "\""
265-
+ " -nunit"
274+
+ " -nunit " + p
266275
Process.spawn runner "mono" args
267276
|> Process.onOutput (fun buffer ->
268277
let outputString = buffer.toString()

0 commit comments

Comments
 (0)