@@ -24,21 +24,21 @@ function getTestOutputChannel(): vscode.OutputChannel {
2424export function registerDotNetTestRunCommand ( server : OmniSharpServer ) : vscode . Disposable {
2525 return vscode . commands . registerCommand (
2626 'dotnet.test.run' ,
27- ( testMethod , fileName ) => runDotnetTest ( testMethod , fileName , server ) ) ;
27+ ( testMethod , fileName , testFrameworkName ) => runDotnetTest ( testMethod , fileName , testFrameworkName , server ) ) ;
2828}
2929
3030export function registerDotNetTestDebugCommand ( server : OmniSharpServer ) : vscode . Disposable {
3131 return vscode . commands . registerCommand (
3232 'dotnet.test.debug' ,
33- ( testMethod , fileName ) => debugDotnetTest ( testMethod , fileName , server ) ) ;
33+ ( testMethod , fileName , testFrameworkName ) => debugDotnetTest ( testMethod , fileName , testFrameworkName , server ) ) ;
3434}
3535
3636// 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 ) {
3838 getTestOutputChannel ( ) . show ( ) ;
3939 getTestOutputChannel ( ) . appendLine ( 'Running test ' + testMethod + '...' ) ;
4040 serverUtils
41- . runDotNetTest ( server , { FileName : fileName , MethodName : testMethod } )
41+ . runDotNetTest ( server , { FileName : fileName , MethodName : testMethod , TestFrameworkName : testFrameworkName } )
4242 . then (
4343 response => {
4444 if ( response . Pass ) {
@@ -54,8 +54,8 @@ export function runDotnetTest(testMethod: string, fileName: string, server: Omni
5454}
5555
5656// 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 => {
5959 vscode . commands . executeCommand (
6060 'vscode.startDebug' , {
6161 "name" : ".NET test launch" ,
@@ -78,18 +78,18 @@ export function updateCodeLensForTest(bucket: vscode.CodeLens[], fileName: strin
7878 return ;
7979 }
8080
81- let testFeature = node . Features . find ( value => value . Name == 'XunitTestMethod' ) ;
81+ let testFeature = node . Features . find ( value => ( value . Name == 'XunitTestMethod' || value . Name == 'NUnitTestMethod' ) ) ;
8282 if ( testFeature ) {
8383 // this test method has a test feature
84-
84+ let testFrameworkName = testFeature . Name == 'XunitTestMethod' ? 'xunit' : 'nunit' ;
8585 bucket . push ( new vscode . CodeLens (
8686 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 ] } ) ) ;
8888
8989 if ( isDebugEnable ) {
9090 bucket . push ( new vscode . CodeLens (
9191 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 ] } ) ) ;
9393 }
9494 }
9595}
0 commit comments