-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Copy link
Labels
affected-mostThis issue impacts most of the customersThis issue impacts most of the customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-mvc-testingMVC testing packageMVC testing packageseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Description
Feedback from @shanselman:
We should do better with testing. There's issues with moving from the inside out:
LEVELS OF TESTING
- GOOD - Unit Testing - Make a PageModel and call On Get
- GOOD - Functional Testing - Make a WebApplicationFactory and make in-memory HTTP calls
- BAD - Automated Browser Testing with Real Server - can't easily use Selenium or call a real server. I shouldn't have to do this. We should decouple the WebApplicationFactory from the concrete TestServer implementation. @davidfowl
public class RealServerFactory<TStartup> : WebApplicationFactory<Startup> where TStartup : class
{
IWebHost _host;
public string RootUri { get; set; }
public RealServerFactory()
{
ClientOptions.BaseAddress = new Uri("https://localhost");
}
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.UseEnvironment("Development"); //will be default in RC1
}
protected override TestServer CreateServer(IWebHostBuilder builder)
{
//Real TCP port
_host = builder.Build();
_host.Start();
RootUri = _host.ServerFeatures.Get<IServerAddressesFeature>().Addresses.FirstOrDefault();
//Fake Server we won't use...sad!
return new TestServer(new WebHostBuilder().UseStartup<TStartup>());
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_host.Dispose();
}
}
}
/cc @javiercn
giggio, ulrichb, M-Yankov, casje, Dreamescaper and 43 more
Sub-issues
Metadata
Metadata
Assignees
Labels
affected-mostThis issue impacts most of the customersThis issue impacts most of the customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-mvc-testingMVC testing packageMVC testing packageseverity-majorThis label is used by an internal toolThis label is used by an internal tool