Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 800
nikib3ro Avatar asked May 24 '18 04:05

nikib3ro


1 Answers

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

like image 173
nikib3ro Avatar answered Oct 30 '22 10:10

nikib3ro