Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for running/debugging NUnit tests #996

Merged
merged 1 commit into from
Dec 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/features/dotnetTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ function getTestOutputChannel(): vscode.OutputChannel {
export function registerDotNetTestRunCommand(server: OmniSharpServer): vscode.Disposable {
return vscode.commands.registerCommand(
'dotnet.test.run',
(testMethod, fileName) => runDotnetTest(testMethod, fileName, server));
(testMethod, fileName, testFrameworkName) => runDotnetTest(testMethod, fileName, testFrameworkName, server));
}

export function registerDotNetTestDebugCommand(server: OmniSharpServer): vscode.Disposable {
return vscode.commands.registerCommand(
'dotnet.test.debug',
(testMethod, fileName) => debugDotnetTest(testMethod, fileName, server));
(testMethod, fileName, testFrameworkName) => debugDotnetTest(testMethod, fileName, testFrameworkName, server));
}

// Run test through dotnet-test command. This function can be moved to a separate structure
export function runDotnetTest(testMethod: string, fileName: string, server: OmniSharpServer) {
export function runDotnetTest(testMethod: string, fileName: string, testFrameworkName: string, server: OmniSharpServer) {
getTestOutputChannel().show();
getTestOutputChannel().appendLine('Running test ' + testMethod + '...');
serverUtils
.runDotNetTest(server, { FileName: fileName, MethodName: testMethod })
.runDotNetTest(server, { FileName: fileName, MethodName: testMethod, TestFrameworkName: testFrameworkName })
.then(
response => {
if (response.Pass) {
Expand All @@ -54,8 +54,8 @@ export function runDotnetTest(testMethod: string, fileName: string, server: Omni
}

// Run test through dotnet-test command with debugger attached
export function debugDotnetTest(testMethod: string, fileName: string, server: OmniSharpServer) {
serverUtils.getTestStartInfo(server, { FileName: fileName, MethodName: testMethod }).then(response => {
export function debugDotnetTest(testMethod: string, fileName: string, testFrameworkName: string, server: OmniSharpServer) {
serverUtils.getTestStartInfo(server, { FileName: fileName, MethodName: testMethod, TestFrameworkName: testFrameworkName }).then(response => {
vscode.commands.executeCommand(
'vscode.startDebug', {
"name": ".NET test launch",
Expand All @@ -78,18 +78,18 @@ export function updateCodeLensForTest(bucket: vscode.CodeLens[], fileName: strin
return;
}

let testFeature = node.Features.find(value => value.Name == 'XunitTestMethod');
let testFeature = node.Features.find(value => (value.Name == 'XunitTestMethod' || value.Name == 'NUnitTestMethod'));
if (testFeature) {
// this test method has a test feature

let testFrameworkName = testFeature.Name == 'XunitTestMethod' ? 'xunit' : 'nunit';
bucket.push(new vscode.CodeLens(
toRange(node.Location),
{ title: "run test", command: 'dotnet.test.run', arguments: [testFeature.Data, fileName] }));
{ title: "run test", command: 'dotnet.test.run', arguments: [testFeature.Data, fileName, testFrameworkName] }));

if (isDebugEnable) {
bucket.push(new vscode.CodeLens(
toRange(node.Location),
{ title: "debug test", command: 'dotnet.test.debug', arguments: [testFeature.Data, fileName] }));
{ title: "debug test", command: 'dotnet.test.debug', arguments: [testFeature.Data, fileName, testFrameworkName] }));
}
}
}
2 changes: 2 additions & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ export namespace V2 {
export interface GetTestStartInfoRequest {
FileName: string;
MethodName: string;
TestFrameworkName: string;
}

export interface GetTestStartInfoResponse {
Expand All @@ -491,6 +492,7 @@ export namespace V2 {
export interface RunDotNetTestRequest {
FileName: string;
MethodName: string;
TestFrameworkName: string;
}

export interface RunDotNetTestResponse {
Expand Down