nikib3ro
nikib3ro

Reputation: 20606

AspNetCore testing with TestHost, WebApplicationTestFixture class not found

I understand that AspNetCore 2.1 is still in release candidate form and that new testing model with Microsoft.AspNetCore.Mvc.Testing is not stabilized.

But I'm trying to follow examples and use WebApplicationTestFixture class for testing. Here is code I have so far:

public class UnitTest1 : IClassFixture<WebApplicationTestFixture<Startup>>
{
    public UnitTest1(WebApplicationTestFixture<Startup> fixture)
    {
        Client = fixture.CreateClient();
    }

    public HttpClient Client { get; }

    [Fact]
    public async void Test1()
    {
        var response = await Client.GetAsync("api/values");

        response.EnsureSuccessStatusCode();
    }
}

However, I can't find WebApplicationTestFixture class in package anywhere. Is it located in additional assembly? Or I'm supposed to create this class?

Upvotes: 9

Views: 651

Answers (1)

nikib3ro
nikib3ro

Reputation: 20606

It seems that during stabilization they've renamed this class. It is now named WebApplicationFactory.

Upvotes: 17

Related Questions