@@ -26,9 +26,10 @@ function! s:debug.prepare(testName, bufferTests) abort
26
26
let bufnr = a: bufferTests [0 ].bufnr
27
27
let tests = a: bufferTests [0 ].tests
28
28
let currentTest = s: utils .findTest (tests, a: testName )
29
- if type (currentTest) != type ({})
29
+ if type (currentTest) != type ([]) || len (currentTest) == 0
30
30
return s: utils .log .warn (' No test found' )
31
31
endif
32
+ let currentTest = currentTest[0 ]
32
33
let project = OmniSharp#GetHost (bufnr ).project
33
34
let targetFramework = project.MsBuildProject.TargetFramework
34
35
let opts = {
@@ -120,18 +121,21 @@ function! s:run.single.test(testName, bufferTests) abort
120
121
let bufnr = a: bufferTests [0 ].bufnr
121
122
let tests = a: bufferTests [0 ].tests
122
123
let currentTest = s: utils .findTest (tests, a: testName )
123
- if type (currentTest) != type ({})
124
+ if type (currentTest) != type ([]) || len (currentTest) == 0
124
125
return s: utils .log .warn (' No test found' )
125
126
endif
126
127
let s: run .running = 1
127
- call OmniSharp#testrunner#StateRunning (bufnr , currentTest.name)
128
+ for ct in currentTest
129
+ call OmniSharp#testrunner#StateRunning (bufnr , ct.name)
130
+ endfor
131
+ let currentTest = currentTest[0 ]
128
132
let project = OmniSharp#GetHost (bufnr ).project
129
133
let targetFramework = project.MsBuildProject.TargetFramework
130
134
let opts = {
131
135
\ ' ResponseHandler' : funcref (' s:run.process' , [s: run .single.complete , bufnr , tests]),
132
136
\ ' BufNum' : bufnr ,
133
137
\ ' Parameters' : {
134
- \ ' MethodName' : currentTest.name,
138
+ \ ' MethodName' : substitute ( currentTest.name, ' (.*)$ ' , ' ' , ' ' ) ,
135
139
\ ' NoBuild' : get (s: , ' nobuild' , 0 ),
136
140
\ ' TestFrameworkName' : currentTest.framework,
137
141
\ ' TargetFrameworkVersion' : targetFramework
@@ -143,6 +147,13 @@ function! s:run.single.test(testName, bufferTests) abort
143
147
endfunction
144
148
145
149
function ! s: run .single.complete (summary) abort
150
+ if len (a: summary .locations) > 1
151
+ " A single test was run, but multiple test results were returned. This can
152
+ " happen when using e.g. NUnit TestCaseSources which re-run the test using
153
+ " different arguments.
154
+ call s: run .multiple.complete ([a: summary ])
155
+ return
156
+ endif
146
157
if a: summary .pass && len (a: summary .locations) == 0
147
158
echomsg ' No tests were run'
148
159
" Do we ever reach here?
@@ -357,9 +368,9 @@ function! s:run.process(Callback, bufnr, tests, response) abort
357
368
if ! has_key (location, ' lnum' )
358
369
" Success, or unexpected test failure.
359
370
let test = s: utils .findTest (a: tests , result.MethodName)
360
- if type (test) == type ({})
361
- let location.lnum = test.nameRange.Start.Line
362
- let location.col = test.nameRange.Start.Column
371
+ if type (test) == type ([]) && len (test) > 0
372
+ let location.lnum = test[ 0 ] .nameRange.Start.Line
373
+ let location.col = test[ 0 ] .nameRange.Start.Column
363
374
let location.vcol = 0
364
375
endif
365
376
endif
@@ -433,17 +444,21 @@ endfunction
433
444
434
445
" Find the test in a list of tests that matches the current cursor position
435
446
function ! s: utils .findTest (tests, testName) abort
436
- for test in a: tests
437
- if a: testName !=# ' '
447
+ if a: testName !=# ' '
448
+ for test in a: tests
438
449
if test.name == # a: testName
439
- return test
450
+ return [ test]
440
451
endif
441
- else
452
+ endfor
453
+ else
454
+ let found = []
455
+ for test in a: tests
442
456
if line (' .' ) >= test.range .Start.Line && line (' .' ) <= test.range .End.Line
443
- return test
457
+ call add (found, test)
444
458
endif
445
- endif
446
- endfor
459
+ endfor
460
+ return found
461
+ endif
447
462
return 0
448
463
endfunction
449
464
0 commit comments