dotnet / dotnet/aspnetcore

No way to pass build arguments to WebApplicationFactory as is

Open
#41,039 9 comments 2 reactions 0 assignees View on GitHub
area-minimal area-mvc feature-mvc-testing investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I try to pass build arguments like `["--flag", "2"]` to my test host but the only result I can get is `--flag=2` or `[["--flag=", "--2="]]`. The reason is this [line](https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Testing/src/DeferredHostBuilder.cs#L46).

### Describe the solution you'd like

Initially I wanted to push just this:

![image](https://user-images.githubusercontent.com/4963385/161648995-41a6e31e-cef9-462e-bb99-d8e53a9ec95d.png)
but then I started to think that `--` symbols might make issues too. If you are interested in, I can prepare a better change where you can avoid `--` as well.

### My current workaround
I just copy/paste DeferredHostBuilder.cs, HostFactoryResolver.cs, WebApplicationFactory.cs and WebApplicationFactoryClientOptions.cs and then do changes inside the project which is awful.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.