Why is the xUnit Runner not finding my tests

后端 未结 8 1302
陌清茗
陌清茗 2020-11-27 05:25

I have a xUnit.net Test as follows:

static class MyTestClass
{
    [Fact]
    static void MyTestMethod() 
    {
    }
         


        
8条回答
  •  春和景丽
    2020-11-27 05:54

    I've been having this issue with .NET Core for a while now where a test class or a test method is not being discovered. The following fix works for me:

    1. Open a command prompt window.
    2. Change to the project directory.
    3. Build the project running the following command:

      dotnet build
      

    NOTE: Building from Visual Studio.NET will not work! <<<<<<<<<<< IMPORTANT!

    1. Run the tests: Test --> Run --> Test All - CTRL+R +A (this will discover the new test(s) - but not run the the new test(s).
    2. Run the tests again.

提交回复
热议问题