No way to pass build arguments to WebApplicationFactory as is
See original GitHub issueIs there an existing issue for this?
- 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.
Describe the solution you’d like
Initially I wanted to push just this:
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.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
AspNet Core Integration test, pass arguments to ...
NET 6.0 and this is how I can achieve passing command-line arguments into my Program.Main(string[] args) from my custom WebApplicationFactory< ...
Read more >Supporting integration tests with WebApplicationFactory in ...
In this post I look at the changes that were made to WebApplicationFactory to support minimal hosting APIs with WebApplicationBuilder in .
Read more >Integration tests in ASP.NET Core
Learn how integration tests ensure that an app's components function correctly at the infrastructure level, including the database, ...
Read more >Overriding configuration in ASP.NET Core integration tests
This post gives an overview of the various ways to override configuration values in ASP.NET Core integration tests.
Read more >Using custom startup class with ASP.NET Core integration ...
My previous post demonstrated how to use custom appsettings.js file with integration tests in ASP.NET Core. But in practice it's not enough ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Sergey-Grudskiy can you send a pull request with your change and a unit test for this scenario? I’d love to see what code you wrote.
Is this issue likely to be resolved? I had a similar requirement where I wanted to pass a command line parameter with no value e.g. on the command line it would look like
myprocess.exe --param
. However,WebApplicationFactory
(orDeferredHostBuilder
) expects all parameters to be key value pairs separated by=
and if there is no value the=
gets appended anyway e.g.myprocess.exe --param=
. Unfortunately, this prevents me running my integration tests as I planned.