SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.25k stars 754 forks source link

Documentation request: .NET 6 example using both specflow.actions.json & appsettings.json #2737

Open A-Rai-col opened 9 months ago

A-Rai-col commented 9 months ago

Product:

What is missing: As a new SpecFlow adventurer 👶🏴‍☠️ , could some brave soul please show me how to setup a .NET 6 + SpecFlow+Selenium using both appsettings.<environment>.json and specflow.actions.<browser>.json, this would probably fit right at home here in the collection. Most of the examples cover one or the other but I think an example using both is missing.

Request Specifics:

Project type:

Multiple (at least 2) environments. appsettings.<environment>.json

appsettings.debug.json

{
    "AppUrl": "http://localhost:4200/"
}

appsettings.release.json

{
    "AppUrl": "http://actualurl.omg"
}

Multiple browser specific configuration.specflow.actions.<browser>.json

specflow.actions.firefox.json It only seems to work with double dash arguments although Firefox arguments are single dashed?

{
    "selenium": {
        "browser": "firefox",
        "arguments": [
            "--private"
        ]
    }
}

specflow.actions.chrome.json

{
    "selenium": {
        "browser": "chrome",
        "arguments": [
            "--start-maximized",
            "--incognito"
        ]
    }
}

specflow.actions.json

{
  "selenium": {
    "defaultTimeout": 60,
    "pollingInterval": 5
  }
}
grajesh690 commented 8 months ago

What I used to do is,

In app settings I used name as,

appsettings.Env.json and have a seperate .runsettings file, that includes, Env details, Browser etc.

so on execution, my command line will be,

dotnet test -s test.runsettings -- TestRunParameters.Parameter(name="Env", value="QA") TestRunParameters.Parameter(name="Browser", value="Chrome")

So my code will pick the appropriate appsettings based on the command given in the terminal.

A-Rai-col commented 8 months ago

Thanks for the tip however, I was looking for a solution using specflow.actions because as far as I understand about it, it will run all the browsers along with their respective specific configurations without having to perform additional actions.

DeLaphante commented 3 weeks ago

I would advised all to not use Specflow+ Runner or LivingDoc as its currently not being supported or developed - migrate to MsTest or Nunit and also update to latest .net 8+ and use third party reporting libraries such as extent report.

Specflow is working perfectly fine for me with the above changes in the following daily github actions repo -> https://github.com/DeLaphante/CynkyAutomation/actions

A-Rai-col commented 2 weeks ago

@DeLaphante Actually the previous maintainers of SpecFlow have created a different project Reqnroll which is being actively maintained.

DeLaphante commented 2 weeks ago

@A-Rai-col - yeah you can also migrate to that but if you don't and still want to use Specflow then its still working perfectly fine when everything is up-to-date - hence the reason i provided a link to my repo