August 8, 2018

SpecFlow Basics

SpecFlow is hands down my favorite testing tool. I’ve been blogging about it since 2013 covering mostly advanced topics. In this post, I’ll go back to the beginning and briefly cover the basics to give you an idea of what it can do. What is SpecFlow? SpecFlow is a tool that allows you to: Define, manage, and automate human-readable acceptance tests in .NET. Enable BDD with easy to understand tests. Read more

October 22, 2017

SpecFlow NUnit3 Generator Plugin

I recently created a SpecFlow plugin to solve a peculiar problem with NUnit test code generation. The issue is SpecFlow will generate test code that doesn’t compile when the .NET project containing the SpecFlow scenarios has a default namespace with the word NUnit. For example, if your project has the namespace IntegrationTests.NUnit, then you’ll receive the following error when trying to build. The type or namespace name ‘Framework’ does not exist in the namespace ‘IntegrationTests. Read more

May 30, 2017

Getting Started with Selenium, SpecFlow, and .NET

Selenium is a library used to automate web browsers. It uses a common web driver interface, and each web browser, Chrome, Firefox, IE, has a corresponding implementation that takes advantage of the browser’s native API. I don’t have much experience with browser automation. In fact, I try to avoid it as much as possible in favor of testing at the unit and service level. Tests running through the browser tend to be brittle due to the non-deterministic nature of web pages. Read more

October 26, 2015

SpecFlow Tags Done Right

In a previous post, I covered scoped bindings in SpecFlow and ended with an example of how not to use tags. In this post, I’ll cover the “right way” and demonstrate how to avoid coupling features to step definitions. But first, a quick primer on tags. What Are Tags? Tags are used in Gherkin to mark features or scenarios. They begin with the @ character in Gherkin, but in step definitions the @ is removed. Read more

October 22, 2015

An Introduction to Scoped Bindings in SpecFlow

One nice aspect of SpecFlow is the ability to scope bindings by feature title, scenario title, or tag. Normally bindings are global to the project, but a binding’s scope can be restricted using the Scope attribute. I like to think of it as similar to the private and public class modifiers in C#. Consider the Gherkin below. It is a single feature with one scenario and two tags. One tag is at the feature level and the other at the scenario level. Read more

September 22, 2015

Refactoring to Composable SpecFlow Steps

I’ve seen some pretty bad SpecFlow code. Code that seems to violate every good practice out there. Poor reuse. Copy and paste everywhere. Test code is the hotel room of the software world. People are sloppier and more careless than they otherwise would be. I’m not sure why that is. Perhaps because tests are not seen as “real code”. But as a testing code base grows from dozens to hundreds to even a thousand or more test cases, having well-factored composable SpecFlow steps becomes critical. Read more

© Joe Buschmann 2020