Skip to content

Commit

Permalink
Merge pull request #19 from AArnott/fix14
Browse files Browse the repository at this point in the history
Respect `methodDisplayOptions`
  • Loading branch information
AArnott authored Apr 24, 2020
2 parents 8dd8b0d + 095d064 commit bea1452
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Xunit.SkippableFact/Sdk/SkippableFactDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptio
{
Requires.NotNull(factAttribute, nameof(factAttribute));
string[] skippingExceptionNames = GetSkippableExceptionNames(factAttribute);
#if NET45
yield return new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
#else
yield return new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod);
#endif
}
}
}
18 changes: 18 additions & 0 deletions src/Xunit.SkippableFact/Sdk/SkippableFactTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ public SkippableFactTestCase(string[] skippingExceptionNames, IMessageSink diagn
this.SkippingExceptionNames = skippingExceptionNames;
}

#if !NET45
/// <summary>
/// Initializes a new instance of the <see cref="SkippableFactTestCase"/> class.
/// </summary>
/// <param name="skippingExceptionNames">An array of the full names of the exception types which should be interpreted as a skipped test-.</param>
/// <param name="diagnosticMessageSink">The diagnostic message sink.</param>
/// <param name="defaultMethodDisplay">The preferred test name derivation.</param>
/// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
/// <param name="testMethod">The test method.</param>
/// <param name="testMethodArguments">The test method arguments.</param>
public SkippableFactTestCase(string[] skippingExceptionNames, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[]? testMethodArguments = null)
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
{
Requires.NotNull(skippingExceptionNames, nameof(skippingExceptionNames));
this.SkippingExceptionNames = skippingExceptionNames;
}
#endif

/// <summary>
/// Gets an array of full names to exception types that should be interpreted as a skip result.
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions src/Xunit.SkippableFact/Sdk/SkippableTheoryDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptio
{
if (testCase is XunitTheoryTestCase)
{
#if NET45
yield return new SkippableTheoryTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, testCase.TestMethod);
#else
yield return new SkippableTheoryTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod);
#endif
}
else
{
#if NET45
yield return new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, testCase.TestMethod, testCase.TestMethodArguments);
#else
yield return new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod, testCase.TestMethodArguments);
#endif
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/Xunit.SkippableFact/Sdk/SkippableTheoryTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ public SkippableTheoryTestCase(string[] skippingExceptionNames, IMessageSink dia
this.SkippingExceptionNames = skippingExceptionNames;
}

#if !NET45
/// <summary>
/// Initializes a new instance of the <see cref="SkippableTheoryTestCase"/> class.
/// </summary>
/// <param name="skippingExceptionNames">An array of the full names of the exception types which should be interpreted as a skipped test-.</param>
/// <param name="diagnosticMessageSink">The diagnostic message sink.</param>
/// <param name="defaultMethodDisplay">The preferred test name derivation.</param>
/// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param>
/// <param name="testMethod">The test method.</param>
public SkippableTheoryTestCase(string[] skippingExceptionNames, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod)
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)
{
Requires.NotNull(skippingExceptionNames, nameof(skippingExceptionNames));
this.SkippingExceptionNames = skippingExceptionNames;
}
#endif

/// <summary>
/// Gets an array of the full names of the exception types which should be interpreted as a skipped test.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Xunit.SkippableFact/Xunit.SkippableFact.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<Description>Make your Xunit test methods self-determine to report a "skipped" result. Useful for such cases as "not supported on this platform" results or other environmental inputs.</Description>
<PackageTags>xunit testing skipping</PackageTags>
</PropertyGroup>
<ItemGroup>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Validation" Version="2.4.18" PrivateAssets="compile;contentfiles;analyzers;build" />
<PackageReference Include="xunit.extensibility.execution" Version="2.1.0" Condition=" '$(TargetFramework)' == 'net45' " />
Expand Down
5 changes: 5 additions & 0 deletions src/Xunit.SkippableFact/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"methodDisplayOptions": "all",
"methodDisplay": "method"
}

0 comments on commit bea1452

Please sign in to comment.