Skip to content

WebApplicationFactory does not work from .NET Framework test assembly #8210

@woodne

Description

@woodne

Describe the bug

When attempting to write tests using the WebApplicationFactory from the Testing project, attempting to create a client against the factory, it blows up because it seems like it is assumed this is being run from a .NET Core assembly.

https://github.com/aspnet/AspNetCore/blob/master/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs#L133

System.InvalidOperationException : The provided Type 'FilterParamsTestStartup' does not belong to an assembly with an entry point. A common cause for this error is providing a Type from a class library.
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureDepsFile()
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer()
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
   at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)

To Reproduce

Steps to reproduce the behavior:

  1. Create a net472 test assembly
  2. create an test that creates a WebapplicationFactory
  3. attempt to call CreateClient for the factory.

Expected behavior

The client is created and tests can be executed from a .net framework assembly.

Metadata

Metadata

Assignees

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesquestion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions