What Project type do I use for Selenium SpecFlow based Visual Studio solution

798 views Asked by At

I am working on building a test automation project for our application using SpecFlow, SpecFlow+ and Selenium WebDriver. Have been going through a few tutorials and each has a different viewpoint.

So can anyone inform what is the best project-type to use with the SpecFlow project and what to use with the Selenium project in the same VS 2019 Solution?

Also, should I have the main project as the SpecFlow and the added project as Selenium (or vice-versa)?

Has anyone done a similar solution with 2 projects that I can have a look at?

2

There are 2 answers

0
Andreas Willich On

If you start with the MSTest, Unit Test or Class Library template doesn't matter. All of them produce a normal class library assembly. The only differences between these project templates are the style (classic or SDK) and the NuGet packages that are added by default.

And in the tutorial of Guru99 they are changing somewhen during the tutorial the project from a console application to a class library.

At the moment I would choose the template depending on which project format you are using in your project. And for that I would follow our "Getting Started"- Guide to choose the right template.

About one or multiple projects: Stay with one project. Why making it more complicated than needed?


Full disclosure: I am the community manager and one of the maintainer of SpecFlow and SpecFlow+

1
RichEdwards On

I use .NET Core class libraries.

  • .Net Framework is going out of support - so i'd avoid that. Chances are they're old tutorials.
  • A console project lets you press "run" as it has the static void main method as the entry point and gives you nice text output where you want it. That's probably why you see it in tutorials as it's easier - but this would eventually just be more effort as you don't run test like program. You'll use a test runner to kick tests off.

Have a look here for an example on github. It's selenium nunit and specflow (not specflow+ or multi project) but it's close enough to give you an idea if you need it. If I had to convert this i'd move the relevant folders to their own project...

In regards to one project vs multiple projects in a solution I would say it's not critical to the design. If you're a beginner, stick with one for now as that reduces the overall complexity. It's not complex to do references but it might slow you down early on.

If you do go with multiple projects - it really doesn't matter what does in first. Probably start from the bottom and do the selenium core stuff first. Nothing will run without selenium so everything will depend on that. You're more likely to swap out the test/data layer later on.