简体   繁体   中英

Hide test from Visual Studio Test Explorer

Using Fact(Skip = "Manual Only") is not entirely satisfactory because, if I click directly on the test to run it, it's still ignored.

I want it to not appear in Test Explorer but I can still run it by clicking on it. Is this possible?

Nice trick from Jimmy Bogard is to use the fact that Skip is writable and react to something in the environment:

public class RunnableInDebugOnlyAttribute : FactAttribute
{
    public RunnableInDebugOnlyAttribute()
    {
        if (!Debugger.IsAttached)
            Skip = "Only running in interactive mode.";
    }
}

(Aside from that, no xUnit does not have an [Interactive] ; the closest thing is `[Trait("Interactive","True")] and use that to either use the trait grouping in test explorer to remove them.

Finally, a 'cheat' way is to use TestDriven.Net, which doesnt care if there is an attribute (along with lots of other facilities).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM