Skip to content

Commit 99dde04

Browse files
committed
Runnable xunit tests with Resharper (#2793)
* Runnable xunit tests with Resharper Visual Studio 2017 RTM and Resharper unit test runner are currently broken: https://youtrack.jetbrains.com/issue/RSRP-464233 This fix allows xunit tests to be runnable within Visual Studio by adding references to the following packages: <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> A consequence of doing this is that Microsoft.NET.Test.Sdk defines a Main entry point which means that Tests project cannot define one. Main renamed to TestMain until this is resolved. * Add comment for Main method rename in Tests project Following PR review (cherry picked from commit 7d3dde8)
1 parent 1c686e4 commit 99dde04

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Tests/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ static Program()
5656
private static string SdkPath { get; }
5757
private static string OutputPath { get; }
5858

59-
public static void Main(string[] args)
59+
// TODO: Renamed this from Main to TestMain because of a bug with Resharper and running unit tests
60+
// in Visual Studio with .NET Core: https://youtrack.jetbrains.com/issue/RSRP-464233
61+
// Once this is fixed, look at renaming back and removing additional packages. See https://github.com/elastic/elasticsearch-net/pull/2793
62+
public static void TestMain(string[] args)
6063
{
6164
if (args.Length == 0)
6265
Console.WriteLine("Must specify at least one argument: TestAssemblyPath, Profile or Benchmark ");

src/Tests/Tests.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@
2323
<PackageReference Include="BenchMarkDotNet" Version="0.10.0" />
2424
<PackageReference Include="DiffPlex" Version="1.4.1" />
2525
<PackageReference Include="System.Reactive" Version="3.1.1" />
26+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
2627
<!-- TODO only for Desktop CLR? -->
2728
<PackageReference Include="System.Buffers" Version="4.3.0" />
2829
<!-- TODO update -->
2930
</ItemGroup>
3031
<ItemGroup Condition="'$(TargetFramework)'!='netcoreapp1.1'">
3132
<PackageReference Include="JetBrains.Profiler.Kernel.Windows.Api" Version="108.0.20170209.151431-eap01" />
3233
<Reference Include="..\..\build\profiling\JetBrains.Profiler.Windows.SelfApi.dll" />
33-
<PackageReference Include="JetBrains.Profiler.Kernel.Windows.Api" Version="108.0.20170209.151431-eap01" />
34+
</ItemGroup>
35+
<ItemGroup Condition="'$(TargetFramework)'!='net45'">
36+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
3437
</ItemGroup>
3538
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp1.1'">
3639
<PackageReference Include="System.Net.Http" Version="4.3.0" />

0 commit comments

Comments
 (0)