Closed JimBobSquarePants closed 2 years ago
Seems like a good idea. The only concern is the connection string as it is created on the fly by the test. But this part could still be handled like today.
The only concern is the connection string as it is created on the fly by the test.
That's um... Odd. Most integration tests will use an SQLite implementation or suchlike.
We require localdb to run the tests which requires creating the connection string in the code for various reasons.
Hiya @JimBobSquarePants,
Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.
We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).
To open it this issue up again, you can write @umbrabot still relevant
in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.
For example:
@umbrabot still relevant This bug can still be reproduced in version
x.y.z
This will reopen the issue in the next few hours.
Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:
In ASP.NET Core environmental settings are loaded without transforms.
The environment itself is determined by the present of the environmental setting
ASPNETCORE_ENVIRONMENT
. By default three values are supported. Development, Staging, and Production.It is often a requirement though to use custom setting during testing. This is possible via
IWebHostBuilder.ConfigureAppConfiguration
used currently in the source...https://github.com/umbraco/Umbraco-CMS/blob/43efee9647ed8f2eaab3ec2b71d3dd3eb46b9017/src/Umbraco.Tests.Integration/TestServerTest/UmbracoWebApplicationFactory.cs#L52-L59
...but there's a better way which allows test settings to sit in an environmental specific
appsettings.Testing.json
file in the same manner as other environments.This is massively beneficial for value discovery for developers contributing to the library since values are easy to find and compare.
Implementing it is trivial. First define an extension environment.
For integration tests wiring it up is as simple as follows.
For unit tests you can create your own
IConfiguration
instance which can then be used for populatingIOptions<T>
instances for testing.That class can now be used to get the full configuration settings.