Skip to content

Commit

Permalink
test without skippableTheory
Browse files Browse the repository at this point in the history
  • Loading branch information
atakavci committed Jan 23, 2025
1 parent 036fad2 commit 9af9968
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 63 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- '**/*.md'
branches:
- master
- ali/fix_ci_wind_tests
pull_request:
schedule:
- cron: "0 1 * * *"
Expand Down
3 changes: 1 addition & 2 deletions tests/NRedisStack.Tests/SkipIfRedisAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public enum Is
}

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer("NRedisStack.Tests.SkippableTheoryDiscoverer", "NRedisStack.Tests")]
public class SkipIfRedisAttribute : SkippableTheoryAttribute
public class SkipIfRedisAttribute : TheoryAttribute
{
private readonly string _targetVersion;
private readonly Comparison _comparison;
Expand Down
61 changes: 0 additions & 61 deletions tests/NRedisStack.Tests/SkippableTheoryDiscoverer.cs
Original file line number Diff line number Diff line change
@@ -1,61 +0,0 @@
using Xunit.Sdk;

namespace NRedisStack.Tests;

// TODO(imalinovskiy): Remove this file once tests are migrated to Xunit v3

/// Copyright (c) Andrew Arnott. All rights reserved.
// Licensed under the Microsoft Public License (Ms-PL).
// https://github.com/AArnott/Xunit.SkippableFact/blob/main/src/Xunit.SkippableFact/Sdk/SkippableTheoryDiscoverer.cs
// See https://github.com/AArnott/Xunit.SkippableFact/blob/main/LICENSE for full license information.

using System.Collections.Generic;
using Validation;
using Xunit.Abstractions;

/// <summary>
/// Patched TestCase discoverer to support SkipIfRedisAttribute.
/// </summary>
public class SkippableTheoryDiscoverer : IXunitTestCaseDiscoverer
{
/// <summary>
/// The diagnostic message sink provided to the constructor.
/// </summary>
private readonly IMessageSink diagnosticMessageSink;

/// <summary>
/// The complex theory discovery process that we wrap.
/// </summary>
private readonly TheoryDiscoverer theoryDiscoverer;

/// <summary>
/// Initializes a new instance of the <see cref="SkippableTheoryDiscoverer"/> class.
/// </summary>
/// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages.</param>
public SkippableTheoryDiscoverer(IMessageSink diagnosticMessageSink)
{
this.diagnosticMessageSink = diagnosticMessageSink;
this.theoryDiscoverer = new TheoryDiscoverer(diagnosticMessageSink);
}

/// <inheritdoc />
public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
Requires.NotNull(factAttribute, nameof(factAttribute));
string[] skippingExceptionNames = new[] { "Xunit.SkippableFact.SkipException" };
TestMethodDisplay defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();

IEnumerable<IXunitTestCase>? basis = this.theoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute);
foreach (IXunitTestCase? testCase in basis)
{
if (testCase is XunitTheoryTestCase)
{
yield return new SkippableTheoryTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod);
}
else
{
yield return new SkippableFactTestCase(skippingExceptionNames, this.diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod, testCase.TestMethodArguments);
}
}
}
}

0 comments on commit 9af9968

Please sign in to comment.