How do I skip specific tests in xUnit based on current platform

后端 未结 5 697
鱼传尺愫
鱼传尺愫 2020-12-15 02:33
  • I have an assembly that I\'ve built on Windows
  • I want to run the xUnit tests on mono in Linux.

However, I have found that while 400 of these te

5条回答
  •  时光取名叫无心
    2020-12-15 03:13

    There is a new options now.

    Add Nuget Package SkippableFact, which allows you to use [SkippableFact] instead of [Fact] and you can use Skip. within a Tests to dynamically Skip the Test during runtime.

    Example:

    [SkippableFact]
    public void SomeTestForWindowsOnly()
    {
        Skip.IfNot(Environment.IsWindows);
    
        // Test Windows only functionality.
    }
    

提交回复
热议问题