Last active
December 31, 2015 20:09
-
-
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..
This file contains 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
[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