.net core: Интеграционное тестирование: Ошибка получения: XUnitTestClassRunner.cs не найден - PullRequest
1 голос
/ 08 марта 2019

Ошибка PFB:

enter image description here

Настройка TestFixture:

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();

    }
}

После создания объекта клиента Fact SearchData не вызывается и получение вышеупомянутой ошибки.

1 Ответ

0 голосов
/ 11 марта 2019

Я решил эту проблему, включив параметр отладки только мой код в меню инструментов из Visual Studio.

Инструменты -> Параметры -> Отладка -> Общие -> Выберите Включить только мои Кодовая опция

...