.net core : Integration testing : Getting error : XUnitTestClassRunner.cs not found

.net core : Integration testing : Getting error : XUnitTestClassRunner.cs not found

PFB 错误:

测试夹具设置:

public TestServerFixture()
    {
        var configuration = new ConfigurationBuilder()
                        .AddJsonFile(@"appsettings.json")
                        .Build();

        //Assembly startupAssembly = typeof(Startup).GetTypeInfo().Assembly;
        //var contentRoot = GetProjectPath(startupAssembly);

        var builder = new WebHostBuilder()
               .UseContentRoot(this.GetContentRootPath())
               .UseEnvironment("Testing").UseConfiguration(configuration)
               .UseStartup<Startup>();  // Uses Start up class from your API Host project to configure the test server

        this._testServer = new TestServer(builder);
        this.Client = this._testServer.CreateClient();
    }

测试方法:

public class SearchControllerTest : IClassFixture<TestServerFixture>
{
    private readonly TestServerFixture _fixture;

    public SearchControllerTest(TestServerFixture fixture)
    {
        _fixture = fixture;
    }

    [Fact]
    public async Task SearchData()
    {
        var response = await _fixture.Client.GetAsync("/api/SearchController/Test");

        response.EnsureSuccessStatusCode();

        var responseStrong = await response.Content.ReadAsStringAsync();

    }
}

After creating the client object Fact SearchData is not getting called and getting above mentioned error.

我已通过 visual studio.

的“工具”菜单中的“只调试我的代码”选项解决了这个问题

Tools -> Options --> Debugging --> General --> Select Enable Just My Code Option