I have a feature files as part of specflow project. The environment in which i need to execute the specflow tests is taken from the parameter mentioned in "appsettings.json".
I want to run a specflow test from command line wherein I would like to have an option to override the parameters in appsettings.json from the command line arguments.
Can this be achieved?
In Hooks.cs file, i am reading the arguments value in BEFORESCENARIO binding.
[BeforeScenario]
public void readarguments()
{
string[] args = Environment.GetCommandLineArguments();
}
I am not able to get env=QA as a string in the array args
I ran the test using below command from command prompt :
dotnet test --filter "TestName1" -- "env=QA"
Command line to be used in git bash--
dotnet test -- TestRunParameters.Parameter\(name="\""Country"\"", value="\""INDIA"\""\)
.runsettings file content --
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<TestRunParameters>
<Parameter name="COUNTRY" value="INDIA" />
</TestRunParameters>
</RunSettings>
Process to access the parameter value in a test --
String _country = TestContext.Parameters["COUNTRY"];