Skip to content

Instantly share code, notes, and snippets.

@sri-prasanna
Last active December 31, 2015 20:09
Show Gist options
  • Save sri-prasanna/8038050 to your computer and use it in GitHub Desktop.
Save sri-prasanna/8038050 to your computer and use it in GitHub Desktop.
A very simple attribute that can be used to record assumptions (if any) for any nunit based tests; after adding this attribute with some assumption text, when the concerned nunit test is run. the assumption text is displayed in the console..
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true) ]
public class TestAssumptionAttribute : TestActionAttribute
{
private readonly string assumption;
public TestAssumptionAttribute(string assumption)
{
this.assumption = assumption;
}
public override void BeforeTest(TestDetails testDetails)
{
Console.WriteLine("This test assumes that : {0}", this.assumption);
base.BeforeTest(testDetails);
}
public override ActionTargets Targets
{
get { return ActionTargets.Test | ActionTargets.Suite; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment