Skip to content

Commit

Permalink
Update for v3 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Jul 6, 2024
1 parent 545df75 commit f72794a
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 93 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,6 @@ dotnet_naming_style.begins_with_i.capitalization = pascal_case

#### Roslyn diagnostics ####

dotnet_diagnostic.CA1851.severity = warning
dotnet_diagnostic.CA1851.severity = warning
dotnet_diagnostic.IDE0057.severity = none
dotnet_diagnostic.IDE1006.severity = none
4 changes: 2 additions & 2 deletions Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<NerdbankGitVersioningVersion>3.6.133</NerdbankGitVersioningVersion>
<NSubstituteVersion>5.1.0</NSubstituteVersion>
<TunnelVisionLabsReferenceAssemblyAnnotatorVersion>1.0.0-alpha.160</TunnelVisionLabsReferenceAssemblyAnnotatorVersion>
<XunitAnalyzersVersion>1.15.0-pre.10</XunitAnalyzersVersion>
<XunitAnalyzersVersion>1.15.0-pre.12</XunitAnalyzersVersion>
<XunitV2Version>2.8.2-pre.12</XunitV2Version>
<XunitV3Version>0.1.1-pre.480</XunitV3Version>
<XunitV3Version>0.2.0-pre.5</XunitV3Version>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions src/xunit.runner.visualstudio/Sinks/IVsDiscoverySink.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Xunit.v3;
using Xunit.Sdk;

namespace Xunit.Runner.VisualStudio;

internal interface IVsDiscoverySink : _IMessageSink, IDisposable
internal interface IVsDiscoverySink : IMessageSink, IDisposable
{
int Finish();
}
23 changes: 10 additions & 13 deletions src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Xunit.Runner.Common;
using Xunit.Sdk;
using Xunit.v3;

#if NETCOREAPP
using System.Reflection;
Expand All @@ -26,12 +25,12 @@ public sealed class VsDiscoverySink : IVsDiscoverySink, IDisposable
static readonly Uri uri = new(Constants.ExecutorUri);

readonly Func<bool> cancelThunk;
readonly _ITestFrameworkDiscoveryOptions discoveryOptions;
readonly ITestFrameworkDiscoveryOptions discoveryOptions;
readonly ITestCaseDiscoverySink discoverySink;
readonly DiscoveryEventSink discoveryEventSink = new();
readonly LoggerHelper logger;
readonly string source;
readonly List<_TestCaseDiscovered> testCaseBatch = new();
readonly List<TestCaseDiscovered> testCaseBatch = [];
readonly TestPlatformContext testPlatformContext;
readonly TestCaseFilter testCaseFilter;

Expand All @@ -40,7 +39,7 @@ public VsDiscoverySink(
IFrontControllerDiscoverer discoverer,
LoggerHelper logger,
ITestCaseDiscoverySink discoverySink,
_ITestFrameworkDiscoveryOptions discoveryOptions,
ITestFrameworkDiscoveryOptions discoveryOptions,
TestPlatformContext testPlatformContext,
TestCaseFilter testCaseFilter,
Func<bool> cancelThunk)
Expand All @@ -61,26 +60,24 @@ public VsDiscoverySink(

public int TotalTests { get; private set; }

public void Dispose()
{
public void Dispose() =>
Finished.Dispose();
}

public static TestCase? CreateVsTestCase(
string source,
_TestCaseDiscovered testCase,
TestCaseDiscovered testCase,
LoggerHelper logger,
TestPlatformContext testPlatformContext)
{
if (testCase.TestClassNameWithNamespace is null)
if (testCase.TestClassName is null)
{
logger.LogErrorWithSource(source, "Error creating Visual Studio test case for {0}: TestClassWithNamespace is null", testCase.TestCaseDisplayName);
return null;
}

try
{
var fqTestMethodName = $"{testCase.TestClassNameWithNamespace}.{testCase.TestMethodName}";
var fqTestMethodName = $"{testCase.TestClassName}.{testCase.TestMethodName}";
var result = new TestCase(fqTestMethodName, uri, source) { DisplayName = Escape(testCase.TestCaseDisplayName) };
result.SetPropertyValue(VsTestRunner.TestCaseUniqueIDProperty, testCase.TestCaseUniqueID);

Expand Down Expand Up @@ -174,7 +171,7 @@ void HandleCancellation(MessageHandlerArgs args)
args.Stop();
}

void HandleTestCaseDiscoveredMessage(MessageHandlerArgs<_TestCaseDiscovered> args)
void HandleTestCaseDiscoveredMessage(MessageHandlerArgs<TestCaseDiscovered> args)
{
testCaseBatch.Add(args.Message);
TotalTests++;
Expand All @@ -185,7 +182,7 @@ void HandleTestCaseDiscoveredMessage(MessageHandlerArgs<_TestCaseDiscovered> arg
HandleCancellation(args);
}

void HandleDiscoveryCompleteMessage(MessageHandlerArgs<_DiscoveryComplete> args)
void HandleDiscoveryCompleteMessage(MessageHandlerArgs<DiscoveryComplete> args)
{
try
{
Expand All @@ -201,7 +198,7 @@ void HandleDiscoveryCompleteMessage(MessageHandlerArgs<_DiscoveryComplete> args)
HandleCancellation(args);
}

bool _IMessageSink.OnMessage(_MessageSinkMessage message) =>
bool IMessageSink.OnMessage(MessageSinkMessage message) =>
discoveryEventSink.OnMessage(message);

private void SendExistingTestCases()
Expand Down
Loading

0 comments on commit f72794a

Please sign in to comment.