Created
October 1, 2013 21:37
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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