Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding ApplicationName on Integration Tests #50316

Open
1 task done
glennfordd opened this issue Aug 24, 2023 · 3 comments
Open
1 task done

Overriding ApplicationName on Integration Tests #50316

glennfordd opened this issue Aug 24, 2023 · 3 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@glennfordd
Copy link

glennfordd commented Aug 24, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

It seems IHostingEnvironment.ApplicationName is always used during integration tests even if I have defined on my appsettings an entry of ApplicationName

I believe this is set via the command line args (automatically by the framework) when running the tests and overriding it via UseSettings with the value from your config, app will throw a FileNotFoundException which makes sense.

Running the app normally seems fine since the command line args is empty anyway

For context, the value on my config is just a generic description of the app (e.g. MyApp), not using minimal API but using top-level statement. Also using .NET6 and ASPNETCore 6

Already seen #11085, #7315, #34914 but none of them work for my scenario

I have tried using WebApplication.CreateBuilder() (without the args) however, it will always use Production settings on integration tests

Is there a proper way to override this?

Expected Behavior

Value from appsettings should be used

Steps To Reproduce

https://github.com/glennfordd/OverrideApplicationName

Exceptions (if any)

No response

.NET Version

6

Anything else?

No response

@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
@amcasey
Copy link
Member

amcasey commented Aug 28, 2023

Thanks for the repro project! The good news is that the desired value is present. The bad news is that it's lower priority than the other value (I'm not yet sure why).

image

@amcasey
Copy link
Member

amcasey commented Aug 28, 2023

Looks like it might be here.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@cthappylife
Copy link

Facing exactly the same problem.
Is there any point to set ApplicationName configuration to the assembly name in the testing?
And has anyone found a way to fix this for integration tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

4 participants