Setting Environment Variables in Developer PowerShell in Visual Studio
While writing UI automated test scenarios using Gherkin SpecFlow framework and C# Steps, I needed to set an environment variable to run a single test case from the command line. In the Windows Command Prompt, I would set the environment variable like this:
Set ENV=envName
For example:
Set ENV=autotests-rc
Then, I would run the test scenario using:
dotnet test --filter FullyQualifiedName=project_api_testing.Features.Admin.Structure.VerifyAdminPayItemsFunctionalityFeature.VerifyUserCanGetPayItemOptions
However, setting the environment variable like this doesn’t work in the Developer PowerShell in Visual Studio. Instead, you need to use the following syntax:
$env:ENV = "autotest-rc"
To run all the test cases from the Developer PowerShell in Visual Studio, I use the following command:
To run the all the test case from the developer power shell in visual studio.
dotnet test ; py .\SanitizeJsonReport.py ; livingdoc test-assembly ./bin/Debug/net6.0/project_api_testing.dll -t ./TestExecution.json
Happy Coding 🙂