Managing BDD features in our project (using TFS)

From time to time I find myself in the position where I ask “stupid” questions. I’ve found that it’s often the case that the question is not that “stupid” after all and if it is you get to learn a lot in the process. I have never been verbally abused, flamed or laughed at for my questions – which often are the reasons that people don’t want to ask “stupid” questions. So recently I’ve been asking “stupid” (final time I use that word in this post, promise) questions surrounding the management of features (.feature-files for us Cucumber freaks). And at the same time I’ve been searching high and low on the net for best practices on how to manage your features through the course of a project. I didn’t find much due to a couple of reasons:

  • The Ruby/cucumber inheritance of .NET tools such as SpecFlow is great...
Read More

Know where you step–generate a step definition report with SpecFlow

In my recent ventures into DOS-country and the SpecFlow.exe I noticed one last flag or subcommand that the SpecFlow.exe accepts; stepdefinitionreport. This subcommand will go through all your features and see which step definitions are called, how many times they are called and also if there is any step definitions that isn’t called at all. OK – that sounds real good, but for the life for me I couldn’t get it to work.

But since the source is open and available from gitHub.com I simply pulled a version down and tried to debug the code. And before long I found the solution. SpecFlow (now 2010-12-16) uses .NET framework 3.5, but my specifications were written using .NET 4.0. There are some reflection going on inside the step definition report code and that doesn’t work very well (loading assemblies from different framework versions).

OK – I simply change...

Read More

SpecFlow.exe and MsTest

With your SpecFlow installation comes SpecFlow.exe, a program that can be used to generate tests from the scenarios and create nicely formatted reports from the generated test results. There’s been a lot written about how to generate these reports when using NUnit (see this and this for example), but there’s been almost silence when it comes to managing this for MsTest. Facing this problem, I can see why… It’s a bit trickier.

In this blog post, I want to show you two things: how to generate MsTests from your .feature files and how to create a report from the generated results. Finally, I’ll show you how to put the two together and link it up to a nice “External tool” button in Visual Studio. Here we go:

Generate MsTests from your .feature file

With this step, you can generate the tests from your scenarios. SpecFlow.exe picks...

Read More

App.config for SpecFlow using MsTest

Every time I need to configure MsTest to work with SpecFlow I forget the syntax of it… Especially the first part…

The fact that it took me about 30 min to write this post is evidence enough that I should not spend any more on this. Here is my reference:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>
 <specFlow>
    <unitTestProvider name="MsTest" />
  </specFlow>
</configuration>

Also there is some additional config setting that you might want to tweak. Here is a complete version with default values:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/>
  </configSections>
 <specFlow>
    <trace traceSuccessfulSteps="true" traceTimings="false" minTracedDuration="0:0:0.1"/>
  </specFlow>
</configuration>
Read More

Using Tags in SpecFlow Features

Since I first read about Cucumber in the excellent RSpec Book, the concept of tags has been one that I haven’t really grasped. I liked the idea as outlined here, which states that you can use tags to organize your features and only run a subset of them. The über-cool @wip tag allows you to limit the number of items in progress for the team, perfect for Kanban lovers.

OK – but when I got around to trying it in SpecFlow, I was a bit disappointed to learn that only @ignore was supported… Or was it?

@ignore

@ignore is the only tag supported by default and is translated to IGNORE in your test framework of choice (for example, Ignore in NUnit or MsTest). This can be used to disable features and/or scenarios...

Read More

Group coding–a knowledge sharing tool

I have the good fortune to from time to time give courses in TDD. I organize these events in two parts; one theoretical background part and then a practical part. During the practical part I found great use of Code Katas in general and the Bowling Ball Kata in specific.

I really like the way that a kata helps you to focus on the thing you trying to learn and in the case of the bowling ball take you through the principles step-by-step.

However, lately I’ve also sheen that the very practice of gathering your team in a room and go through a coding exercise on a screen together, taking turns at the keyboard, has yet another great benefit. You start to talk about your code.

In this case you can together create a shared understanding, shared principles and code standard and finally build the team...

Read More

The Emperor is Naked—Don’t Ask Me to Estimate!

This is a well-known truth for all practicing agile methods.

Introduction

I’m currently working on a migration project with a fantastic team—possibly the best I’ve ever worked with. We’re converting a large VB6 application to VB.NET and WPF. Due to various reasons, we decided to do this in two phases:

  1. Migrate everything with a tool and then get it to work again. Write an integration test that ensures the function works as expected.
  2. Rewrite the underlying architecture bit by bit. Since we have integration tests in place, we are shielded from introducing any significant bugs.

In the first phase, we worked our way through the old code, form by form. There were 265 forms, and we created a simple tracking tool in Excel to classify each form as S, M, L, or XL (based on size in KB). As we progressed, we tracked the time spent...

Read More

Should & Substitute – Two New Great Friends

Recently, I discovered two fantastic frameworks that have significantly improved my test code: Should and NSubstitute.

Should I? Yes – You Should

First up is Should, an assertion framework that enhances the readability and ease of writing assertions. Here’s an example showcasing its capabilities:

object obj = new object(); obj.Should().Be.OfType(typeof(object)); obj.Should().Equal(obj); obj.Should().Not.Be.Null(); obj.Should().Not.Be.SameAs(new object()); obj.Should().Not.Be.OfType<string>(); obj.Should().Not.Equal("foo"); "This String".Should().Contain("This"); "This String"

      Read More
    

No more bugs – a thought experiment

I’m reading the excellent Switch: How to Change Things When Change Is Hard. And in it I stumbled on a interesting story, and when I started to think about how it could be applied in the Software development world I really got excited. But all in due time. Here is the story, in my shortened and simplified form (be sure to buy the book):

BP

The example is taken from a chapter (4) called Point to the destination that talks about good ways to show people where the goal is. Surrounding this example they are talking about sending a postcard from the future; Hey, look how warm and wonderful everything is here in the future when we have changed all that stuff…

Then the authors gives an example from BP (Yeah, I know that might sit bad with most people nowadays but forget the well in the...

Read More

Different appSetttings for each developer in the team - part II

In my last post I asked for comments, and it didn’t take Anders (Granåker) very long time to come up with a better and more correct solution to the problem.

The downside of my solution is that you need to tweak the build process on a build server for example. We knew that BUT I left it for later solving. There is a rename to be done and a moving of the real app.config etc.

OK - the solution has to do with the file-attribute on the AppSettings-node in .config-files. With that attribute you can point to another file that contains one or more keys from the appSettings-node. Two important things about that:

  1. If the file is not present it will use the settings in the original app.config
  2. If the file is present the settings in it will override any attributes that are specified in both places
  3. ...
Read More