Created
February 3, 2020 07:26
-
-
Save 0x49D1/c664781154b61c31cde344f232447f61 to your computer and use it in GitHub Desktop.
Ignore xUnit test when running tests not in DEBUG mode.
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
/// <summary> | |
/// Credits to https://lostechies.com/jimmybogard/2013/06/20/run-tests-explicitly-in-xunit-net/ | |
/// </summary> | |
public class RunnableInDebugOnlyAttribute : FactAttribute | |
{ | |
public RunnableInDebugOnlyAttribute() | |
{ | |
if (!Debugger.IsAttached) | |
{ | |
Skip = "Only running in interactive mode."; | |
} | |
} | |
} | |
//// After that just use the attribute `RunnableInDebugOnlyAttribute` instead of `Fact` when you want the test to be ignored in automatic runs without debug, for example | |
// Example of method in test suite | |
// [RunnableInDebugOnlyAttribute()] | |
// public void Test() | |
// { | |
// Runs only in debug mode | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment