Home » SpecFlow » What is SpecFlow…

What is SpecFlow…

…And why do I want it?

SpecFlowThat’s what I kept asking myself every time I saw this product.

Well, the last time I looked, something caught my eye enough that I decided to download it and take a look. I’m really glad I did it.

So, let me attempt to explain what SpecFlow is.

First, while you can get SpecFlow+ Runner to run your test, this isn’t a completely new testing platform. Instead, it is a testing platform that works with whatever testing platform you are using to test your .NET code. So, it works with NUnit, MSTest, xUnit and MbUnit. This is good for my situation because any test I write with SpecFlow will continue to work with the tools I already have in place. Including my current test runners (ReSharper) and my Continuous Integration system (TeamCity). I wasn’t interested in adopting a platform that wouldn’t work with these two platforms.

Where I got Confused

Now the part that kept me from looking at this framework for such a long time was the home page. If you go there, you will see the “Three easy steps.” 1) Specify, 2) Automate, 3) enjoy.

Well, at first glance it looked like was going to have to write my test in English and then write my test in code and then I could enjoy. Why would I want to do that?

So, the part they forgot to mention is that once you’ve specified your test, the Visual Studio plugin will generate your test code for you. For NUnit it actually writes the NUnit test for you.

The code you do have to write is the code that translates the individual steps. But even that code gets stubbed out for you.

Once you have enough of those stubbed out, to write a test, you just write the test in English, save the file, and run the test.

Now that I finally understand this, I like most of what SpecFlow does. But there are a few things I wish it did differently.

What I like:

1) It puts my test in a Given, When, Then structure like I mentioned a few weeks ago.

2) The class files it generates are all partial classes. This allowed me to keep my inheritance structure that I’m dependent on for my current NUnit testing framework. And allowed me to work around one of the shortcomings I’ve found.

3) The methods are all virtual, again, allowing for extension and flexibility.

4) Intellisense is enabled so you can see similar sentences you’ve already used as you are creating new test.

5) You can create tables of parameters for test scenarios, similar to how you can pass multiple parameters to an NUnit test with the TestCase attribute or the TestCaseSource attribute.

6) To write the supporting CSharp, code I didn’t have to learn anything new.

7) I can give the English language, none code, document to the business user and they should be able to read the test well enough to tell me if the test is an accurate reflection of what they want the system to do.

What I don’t like:

1) I’ve become pretty dependent on the NUnit TestFixture attribute that allows me to pass parameters to the entire test. I use this to control the testing of multiple browsers. But, I’ve recently figured out a way to run all of my browsers simultaneously rather than sequentially so I won’t need this feature in the pretty near future. Once I’ve got that working, you can be sure I’ll share it here. So, don’t forget to subscribe to this blog if you haven’t already.


Other post in SpecFlow

Related Post

  • Setting up SpecFlowSetting up SpecFlow I’ve been asked to train a group of developers in the use of SpecFlow so that they can use it to write Selenium Tests.  So, in an attempt to “kill two birds with one stone” I thought […]
  • SpecFlow StrategySpecFlow Strategy A while ago I wrote an article explaining what SpecFlow is, and why you might want to use it.  I’ve been using it for several months now and I’ve recognized several patterns that have […]
  • NUnit 2 vs NUnit 3.  What you need to know.NUnit 2 vs NUnit 3. What you need to know. NUnit 3 recently released and if you’ve picked it up you’ve probably already found that there are several changes between version 3 and version 2.If you haven’t, here are some […]
  • Running Selenium In Parallel With Any .NET Unit Testing ToolRunning Selenium In Parallel With Any .NET Unit Testing Tool Running Selenium in parallel from .NET seems to be a problem because, as of the time of this writing, I’ve yet to find a viable way of running selenium test on multiple browsers using […]
  • SpecFlow TutorialSpecFlow Tutorial A couple of weeks ago, I wrote a post describing how to setup SpecFlow in which I promised to continue with how to actually use it once you have it installed.  What follows is a SpecFlow […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer focusing on ASP.NET, C#, Node.js, JavaScript, HTML, CSS, BootStrap, and Angular.JS.Does your team need additional help in any of the above? Contact Dave today.

One Pingback/Trackback