/// <inheritdoc/> public override IEnumerable <IXunitTestCase> Discover( ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute ) { var baseCases = base.Discover(discoveryOptions, testMethod, factAttribute); if (!String.IsNullOrEmpty(factAttribute.GetNamedArgument <string>("Skip"))) { // No need to change skipped tests. return(baseCases); } var platforms = factAttribute.GetNamedArgument <Platform>("Platforms"); if ((platforms & Platform) != 0) { // No need to change tests that should run on the current platform. return(baseCases); } // Base implementation always returns a single test case. var baseCase = baseCases.FirstOrDefault(); Contract.Assert(baseCase != null); if (baseCase is ExecutionErrorTestCase) { // No need to change an erroneous test. return(baseCases); } if (!String.IsNullOrEmpty(baseCase.SkipReason)) { // No need to change a skipped test. Covered to protect against changes in the base class. return(baseCases); } // Replace test with its skipped equivalent. var platformJustification = factAttribute.GetNamedArgument <string>( "PlatformJustification" ); var skipReason = String.Format( platformJustification, platforms.ToString().Replace(", ", " | "), Platform ); var testCase = new SkippedXunitTestCase( _diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), skipReason, baseCase.TestMethod, baseCase.TestMethodArguments ); return(new[] { testCase }); }
/// <inheritdoc/> public override IEnumerable <IXunitTestCase> Discover( ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) { var baseCases = base.Discover(discoveryOptions, testMethod, theoryAttribute); if (!String.IsNullOrEmpty(theoryAttribute.GetNamedArgument <string>("Skip"))) { // No need to change skipped tests. return(baseCases); } var platforms = theoryAttribute.GetNamedArgument <Platform>("Platforms"); if ((platforms & Platform) != 0) { // No need to change tests that should run on the current platform. return(baseCases); } // Update the individual test cases as needed: Skip test cases that would otherwise run. var testCases = new List <IXunitTestCase>(); var platformJustification = theoryAttribute.GetNamedArgument <string>("PlatformJustification"); var skipReason = String.Format(platformJustification, platforms.ToString().Replace(", ", " | "), Platform); foreach (var baseCase in baseCases) { if (baseCase is ExecutionErrorTestCase) { // No need to change an erroneous test. Covered to protect against changes in the base class. testCases.Add(baseCase); continue; } if (!String.IsNullOrEmpty(baseCase.SkipReason)) { // No need to change a skipped test. Likely to hit this case only after xUnit.net has been updated // to 2.2.0+, where [Data] also has a Skip property. testCases.Add(baseCase); continue; } var testCase = new SkippedXunitTestCase( _diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), skipReason, baseCase.TestMethod, baseCase.TestMethodArguments); testCases.Add(testCase); } return(testCases); }