Skip to content

Instantly share code, notes, and snippets.

@robfe
Created October 1, 2013 21:37
Show Gist options
  • Save robfe/6785524 to your computer and use it in GitHub Desktop.
Save robfe/6785524 to your computer and use it in GitHub Desktop.
Hack a Fact subclass into your current project to make specflow skip any tests with pending steps. Ultra dirty/unfinished
extern alias rxu; //alias the xunit dll to "rxu" - Real X Unit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using TechTalk.SpecFlow;
namespace Xunit
{
public class FactAttribute:rxu.Xunit.FactAttribute
{
protected override IEnumerable<rxu::Xunit.Sdk.ITestCommand> EnumerateTestCommands(rxu::Xunit.Sdk.IMethodInfo method)
{
var testCommands = base.EnumerateTestCommands(method).Select(command => (rxu::Xunit.Sdk.ITestCommand) new MaybeSkipCommand(command, method));
return testCommands;
}
}
internal class MaybeSkipCommand : rxu::Xunit.Sdk.ITestCommand
{
readonly rxu::Xunit.Sdk.ITestCommand _inner;
readonly rxu::Xunit.Sdk.IMethodInfo _method;
public MaybeSkipCommand(rxu::Xunit.Sdk.ITestCommand inner, rxu::Xunit.Sdk.IMethodInfo method)
{
_inner = inner;
_method = method;
}
public rxu::Xunit.Sdk.MethodResult Execute(object testClass)
{
try
{
return _inner.Execute(testClass);
}
catch (SpecFlowException e)
{
return new rxu::Xunit.Sdk.SkipResult(_method, DisplayName, e.Message);
}
}
public XmlNode ToStartXml()
{
return _inner.ToStartXml();
}
public string DisplayName
{
get { return _inner.DisplayName; }
}
public bool ShouldCreateInstance
{
get { return _inner.ShouldCreateInstance; }
}
public int Timeout
{
get { return _inner.Timeout; }
}
}
public class TraitAttribute : rxu.Xunit.TraitAttribute
{
public TraitAttribute(string name, string value) : base(name, value)
{
}
}
public interface IUseFixture<T> : rxu.Xunit.IUseFixture<T> where T : new()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment