how to pull environment variable from application project to specflow project?
Update more specifically:
I added SpecFlow project along with the application project in the same solution.
The expectation is that while the application project (i.e. ASP .Net API project extract a specific environment variable, I need the specFlow project can get the same environment variable as well and then kick off the SpecFlow tests for that test environment.
I don't have a solution for this yet.
Below is the context:
Visual Studio 2022 Enterprise. SpecFlow Nunit 3.9
Under ABC solution:
- ApplicationAPI project
- SpecFlow.Test project
Environment Variables could be: Local, Dev, Test, Pre, Prod.
How can I get different environment to load different configuration from "appsettings.{env.EnvironmentName}.json" in the specFlow project
config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
-
What exactly do you want to be dependent on a value of an environment variable?
You always can use `Environment.GetEnvironmentVariable` in your bindings.
0 -
Hi, Andreas,
Can you please elaborate more details about this?
According to .Net reference https://docs.microsoft.com/en-us/dotnet/api/system.environment.getenvironmentvariable?view=net-6.0#system-environment-getenvironmentvariable(system-string)
GetEnvironmentVariable (string variable);
what string variable should I put in here? How do I set Environment Variable for a specflow project on a machine?
Thanks
0
Please sign in to leave a comment.
Comments
2 comments