Apologies, if this has already been asked, but please bare with me, i am new to restSharp and API testing. I have ready many posts,articles and responses. But due to my limitation, I was wondering if anyone can just guide me through, on how to achieve it.
What i would like to achieve, is to run the same test scenario in different test environments(dev, uat, pro etc..) for the same Gherkin scenarios, if possible by making use of the tags e.g @dev @uat etc..
Currently, we have 3 runsetting files for each of these environments, (dev.runsetting, uat.runsetting etc..in each we pass different parameters), to change to different environment, i do this through C# and select the necessary test setting files
If I understood you correctly, you want to control via tags which scenario is executed against which environment.
The SpecFlow+ Runner has a feature called
Targets
that could help you. With this, you can define multiple targets and their configuration, for your scenarios.You can find an example for this feature here: https://github.com/SpecFlowOSS/SpecFlow.Plus.Examples/tree/master/SeleniumWebTest
In this example, we are using the targets to test against different browsers.
In your case, I would change the browser to your environments.
In your CI/CD pipeline, you could then use the filtering in the SpecFlow+ Runner to filter out for your different environments. In Azure DevOps the filter criteria is
Name~\(target: <TARGETNAME>\)
.Documentation for it is here: https://docs.specflow.org/projects/specflow-runner/en/latest/Profile/Filter.html
Full disclosure: I am one of the maintainers and developers on SpecFlow and SpecFlow+