question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No way to pass build arguments to WebApplicationFactory as is

See original GitHub issue

Is 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:

image 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:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
davidfowlcommented, Apr 13, 2022

@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.

0reactions
kierondye-fraedomcommented, Jun 16, 2023

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 (or DeferredHostBuilder) 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found