@@ -24,21 +24,21 @@ function getTestOutputChannel(): vscode.OutputChannel {
24
24
export function registerDotNetTestRunCommand ( server : OmniSharpServer ) : vscode . Disposable {
25
25
return vscode . commands . registerCommand (
26
26
'dotnet.test.run' ,
27
- ( testMethod , fileName ) => runDotnetTest ( testMethod , fileName , server ) ) ;
27
+ ( testMethod , fileName , testFrameworkName ) => runDotnetTest ( testMethod , fileName , testFrameworkName , server ) ) ;
28
28
}
29
29
30
30
export function registerDotNetTestDebugCommand ( server : OmniSharpServer ) : vscode . Disposable {
31
31
return vscode . commands . registerCommand (
32
32
'dotnet.test.debug' ,
33
- ( testMethod , fileName ) => debugDotnetTest ( testMethod , fileName , server ) ) ;
33
+ ( testMethod , fileName , testFrameworkName ) => debugDotnetTest ( testMethod , fileName , testFrameworkName , server ) ) ;
34
34
}
35
35
36
36
// Run test through dotnet-test command. This function can be moved to a separate structure
37
- export function runDotnetTest ( testMethod : string , fileName : string , server : OmniSharpServer ) {
37
+ export function runDotnetTest ( testMethod : string , fileName : string , testFrameworkName : string , server : OmniSharpServer ) {
38
38
getTestOutputChannel ( ) . show ( ) ;
39
39
getTestOutputChannel ( ) . appendLine ( 'Running test ' + testMethod + '...' ) ;
40
40
serverUtils
41
- . runDotNetTest ( server , { FileName : fileName , MethodName : testMethod } )
41
+ . runDotNetTest ( server , { FileName : fileName , MethodName : testMethod , TestFrameworkName : testFrameworkName } )
42
42
. then (
43
43
response => {
44
44
if ( response . Pass ) {
@@ -54,8 +54,8 @@ export function runDotnetTest(testMethod: string, fileName: string, server: Omni
54
54
}
55
55
56
56
// Run test through dotnet-test command with debugger attached
57
- export function debugDotnetTest ( testMethod : string , fileName : string , server : OmniSharpServer ) {
58
- serverUtils . getTestStartInfo ( server , { FileName : fileName , MethodName : testMethod } ) . then ( response => {
57
+ export function debugDotnetTest ( testMethod : string , fileName : string , testFrameworkName : string , server : OmniSharpServer ) {
58
+ serverUtils . getTestStartInfo ( server , { FileName : fileName , MethodName : testMethod , TestFrameworkName : testFrameworkName } ) . then ( response => {
59
59
vscode . commands . executeCommand (
60
60
'vscode.startDebug' , {
61
61
"name" : ".NET test launch" ,
@@ -78,18 +78,18 @@ export function updateCodeLensForTest(bucket: vscode.CodeLens[], fileName: strin
78
78
return ;
79
79
}
80
80
81
- let testFeature = node . Features . find ( value => value . Name == 'XunitTestMethod' ) ;
81
+ let testFeature = node . Features . find ( value => ( value . Name == 'XunitTestMethod' || value . Name == 'NUnitTestMethod' ) ) ;
82
82
if ( testFeature ) {
83
83
// this test method has a test feature
84
-
84
+ let testFrameworkName = testFeature . Name == 'XunitTestMethod' ? 'xunit' : 'nunit' ;
85
85
bucket . push ( new vscode . CodeLens (
86
86
toRange ( node . Location ) ,
87
- { title : "run test" , command : 'dotnet.test.run' , arguments : [ testFeature . Data , fileName ] } ) ) ;
87
+ { title : "run test" , command : 'dotnet.test.run' , arguments : [ testFeature . Data , fileName , testFrameworkName ] } ) ) ;
88
88
89
89
if ( isDebugEnable ) {
90
90
bucket . push ( new vscode . CodeLens (
91
91
toRange ( node . Location ) ,
92
- { title : "debug test" , command : 'dotnet.test.debug' , arguments : [ testFeature . Data , fileName ] } ) ) ;
92
+ { title : "debug test" , command : 'dotnet.test.debug' , arguments : [ testFeature . Data , fileName , testFrameworkName ] } ) ) ;
93
93
}
94
94
}
95
95
}
0 commit comments