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

Get NUnit test running/debugging working #834

Merged
merged 3 commits into from
Apr 27, 2017
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
16 changes: 11 additions & 5 deletions src/OmniSharp.DotNetTest/VSTestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ namespace OmniSharp.DotNetTest
{
internal class VSTestManager : TestManager
{
private const string DefaultRunSettings = "<RunSettings />";

public VSTestManager(Project project, string workingDirectory, DotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
: base(project, workingDirectory, dotNetCli, eventEmitter, loggerFactory.CreateLogger<VSTestManager>())
{
}

protected override string GetCliTestArguments(int port, int parentProcessId)
{
return $"vstest --Port:{port} --ParentProcessId:{parentProcessId}";
return $"vstest --Port:{port} --ParentProcessId:{parentProcessId}";
}

protected override void VersionCheck()
Expand Down Expand Up @@ -86,7 +88,8 @@ public override GetTestStartInfoResponse GetTestStartInfo(string methodName, str
new
{
TestCases = testCases,
DebuggingEnabled = true
DebuggingEnabled = true,
RunSettings = DefaultRunSettings
});

var message = ReadMessage();
Expand All @@ -110,7 +113,8 @@ public override async Task<DebugTestGetStartInfoResponse> DebugGetStartInfoAsync
new
{
TestCases = testCases,
DebuggingEnabled = true
DebuggingEnabled = true,
RunSettings = DefaultRunSettings
});

var message = await ReadMessageAsync(cancellationToken);
Expand Down Expand Up @@ -170,7 +174,8 @@ public override RunTestResponse RunTest(string methodName, string testFrameworkN
SendMessage(MessageType.TestRunSelectedTestCasesDefaultHost,
new
{
TestCases = testCases
TestCases = testCases,
RunSettings = DefaultRunSettings
});

var done = false;
Expand Down Expand Up @@ -224,7 +229,8 @@ private async Task<TestCase[]> DiscoverTestsAsync(string methodName, Cancellatio
Sources = new[]
{
Project.OutputFilePath
}
},
RunSettings = DefaultRunSettings
});

var testCases = new List<TestCase>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit" Version="3.6.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0-ci-00452-pr-313" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions test-assets/test-projects/NUnitTestProject/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AppVeyor NUnit CI Feed" value="https://ci.appveyor.com/nuget/nunit" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but you don't need this line/feed unless you want to pull in pre-release versions of the NUnit Framework. The adapter PR only uses the Engine and Adapter feeds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as there's an NUnitTestAdapter on nuget.org that we can use, I'll just delete this file.

<add key="AppVeyor NUnit Engine CI Feed" value="https://ci.appveyor.com/nuget/nunit-console" />
<add key="AppVeyor NUnit Adapter CI Feed" value="https://ci.appveyor.com/nuget/nunit3-vs-adapter" />
<add key="NUnit MyGet Feed" value="https://www.myget.org/F/nunit/api/v2" />
</packageSources>
</configuration>
2 changes: 1 addition & 1 deletion tests/OmniSharp.DotNetTest.Tests/AbstractRunTestFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class AbstractRunTestFacts : AbstractTestFixture
protected const string LegacyXunitTestProject = "LegacyXunitTestProject";
protected const string LegacyNunitTestProject = "LegacyNunitTestProject";
protected const string XunitTestProject = "XunitTestProject";
protected const string NunitTestProject = "NunitTestProject";
protected const string NUnitTestProject = "NUnitTestProject";

public AbstractRunTestFacts(ITestOutputHelper testOutput)
: base(testOutput)
Expand Down
19 changes: 8 additions & 11 deletions tests/OmniSharp.DotNetTest.Tests/RunTestFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,44 +65,41 @@ public async Task RunXunitTestWithSimilarName()
Assert.Equal(1, response.Results.Length);
}

// NUnit does not work with .NET CLI RTM yet. https://github.com/nunit/dotnet-test-nunit/issues/108
// When it does, the NUnitTestProject should be updated and the tests below re-enabled.

//[Fact]
[Fact]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing NUnit with xUnit, ironic 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, NUnit doesn't work yet, so...

public async Task RunNunitTest()
{
await RunDotNetTestAsync(
NunitTestProject,
NUnitTestProject,
methodName: "Main.Test.MainTest.Test",
testFramework: "nunit",
shouldPass: true);
}

//[Fact]
[Fact]
public async Task RunNunitDataDriveTest1()
{
await RunDotNetTestAsync(
NunitTestProject,
NUnitTestProject,
methodName: "Main.Test.MainTest.DataDrivenTest1",
testFramework: "nunit",
shouldPass: false);
}

//[Fact]
[Fact]
public async Task RunNunitDataDriveTest2()
{
await RunDotNetTestAsync(
NunitTestProject,
NUnitTestProject,
methodName: "Main.Test.MainTest.DataDrivenTest2",
testFramework: "nunit",
shouldPass: true);
}

//[Fact]
[Fact]
public async Task RunNunitSourceDataDrivenTest()
{
await RunDotNetTestAsync(
NunitTestProject,
NUnitTestProject,
methodName: "Main.Test.MainTest.SourceDataDrivenTest",
testFramework: "nunit",
shouldPass: true);
Expand Down