diff --git a/Versions.props b/Versions.props
index 5fb0749..abb4eb5 100644
--- a/Versions.props
+++ b/Versions.props
@@ -12,7 +12,7 @@
1.0.0-alpha.160
1.16.0-pre.23
2.9.1-pre.8
- 0.2.0-pre.80
+ 0.2.0-pre.87
diff --git a/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs b/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs
index 2c9c631..9a7bd4f 100644
--- a/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs
+++ b/src/xunit.runner.visualstudio/Sinks/VsDiscoverySink.cs
@@ -79,6 +79,7 @@ public void Dispose() =>
var fqTestMethodName = $"{testCase.TestClassName}.{testCase.TestMethodName}";
var result = new VsTestCase(fqTestMethodName, uri, source) { DisplayName = Escape(testCase.TestCaseDisplayName) };
result.SetPropertyValue(VsTestRunner.TestCaseUniqueIDProperty, testCase.TestCaseUniqueID);
+ result.SetPropertyValue(VsTestRunner.TestCaseExplicitProperty, testCase.Explicit);
if (testPlatformContext.DesignMode)
result.SetPropertyValue(VsTestRunner.TestCaseSerializationProperty, testCase.Serialization);
diff --git a/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs b/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs
index 4c2e167..9108620 100644
--- a/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs
+++ b/src/xunit.runner.visualstudio/Utility/AssemblyRunInfo.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Xunit.Runner.Common;
+using Xunit.Sdk;
namespace Xunit.Runner.VisualStudio;
@@ -11,12 +12,14 @@ public class AssemblyRunInfo
RunSettings runSettings,
string assemblyFileName,
AssemblyMetadata assemblyMetadata,
- IList? testCases)
+ IList? testCases,
+ bool runExplicitTests)
{
Assembly = new XunitProjectAssembly(project, assemblyFileName, assemblyMetadata);
TestCases = testCases;
runSettings.CopyTo(Assembly.Configuration);
+ Assembly.Configuration.ExplicitOption = runExplicitTests ? ExplicitOption.On : ExplicitOption.Off;
}
public XunitProjectAssembly Assembly { get; }
@@ -27,12 +30,13 @@ public class AssemblyRunInfo
XunitProject project,
RunSettings runSettings,
string assemblyFileName,
- IList? testCases = null)
+ IList? testCases = null,
+ bool runExplicitTests = false)
{
var metadata = AssemblyUtility.GetAssemblyMetadata(assemblyFileName);
if (metadata is null || metadata.XunitVersion == 0)
return null;
- return new(project, runSettings, assemblyFileName, metadata, testCases);
+ return new(project, runSettings, assemblyFileName, metadata, testCases, runExplicitTests);
}
}
diff --git a/src/xunit.runner.visualstudio/VsTestRunner.cs b/src/xunit.runner.visualstudio/VsTestRunner.cs
index d7cd4cf..d1e8109 100644
--- a/src/xunit.runner.visualstudio/VsTestRunner.cs
+++ b/src/xunit.runner.visualstudio/VsTestRunner.cs
@@ -119,6 +119,9 @@ public class VsTestRunner : ITestDiscoverer, ITestExecutor
"xunit.v3.runner.utility.netstandard20.dll",
};
+ public static TestProperty TestCaseExplicitProperty { get; } =
+ TestProperty.Register("XunitTestCaseExplicit", "xUnit.net Test Case Explicit Flag", typeof(bool), typeof(VsTestRunner));
+
public static TestProperty TestCaseSerializationProperty { get; } =
TestProperty.Register("XunitTestCaseSerialization", "xUnit.net Test Case Serialization", typeof(string), typeof(VsTestRunner));
@@ -382,6 +385,7 @@ public void RunTests(
var logger = new LoggerHelper(frameworkHandle, stopwatch);
var project = new XunitProject();
var runSettings = RunSettings.Parse(runContext?.RunSettings?.SettingsXml);
+ var runExplicitTests = tests.All(testCase => testCase.GetPropertyValue(TestCaseExplicitProperty, false));
using var _ = AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), new DiagnosticMessageSink(logger, showInternalDiagnostics: runSettings.InternalDiagnosticMessages ?? false));
@@ -396,7 +400,7 @@ public void RunTests(
() =>
tests
.GroupBy(testCase => testCase.Source)
- .Select(group => AssemblyRunInfo.Create(project, runSettings, group.Key, [.. group]))
+ .Select(group => AssemblyRunInfo.Create(project, runSettings, group.Key, [.. group], runExplicitTests))
.WhereNotNull()
.ToList()
).GetAwaiter().GetResult();
diff --git a/test/test.v3/Tests.cs b/test/test.v3/Tests.cs
index 5c83b6a..4282b24 100644
--- a/test/test.v3/Tests.cs
+++ b/test/test.v3/Tests.cs
@@ -5,11 +5,11 @@ public class Tests
[Fact]
public void Passing() { }
- [Fact]
+ [Fact(Explicit = true)]
public void Failing() => Assert.Fail("This is a failing test");
[Theory]
- [InlineData(true)]
+ [InlineData(true, Explicit = true)]
[InlineData(false)]
public void ConditionalSkip(bool value) => Assert.SkipWhen(value, "Conditionally skipped");
}