Developing in .Net–a new era has begun

News The other day I just realized how much have changed in the way we develop code nowadays. Well it might just be me but it’s certainly some major changes that has taken place in the .NET development arena. I don’t claim this to be in the right chronological order but here are some major milestones for me: TDD – didn’t use just 2 years back BDD – finally get the requirements and tester into the agile loop and an opportunity to work outside in which feels just right for me. My favorite tool right now of course is SpecFlow. LINQ – totally changed the way C# (VB.NET still sucks at LINQ if you ask me) looks ASP.NET MVC – a web framework that makes sense. And that you can test. I understand again. And now the other day (the day of the many updates as it might well be...
Read More

Specification by example with SpecFlow in TFS and the question of traceability

This is the second post talking about how to integrate the use of Team Foundation Server (TFS) in a Specification by example (BDD, ATDD call it what you want) workflow. You can read the first post here for some background, but I will include some background here too, as I have thought about it some more. Background Specification by example is not only a way to write executable specifications (red. those words still gives me the chills) but in the way it’s used in projects lies some kind of agile methodology hidden. The early and frequent communication and documentation (in a commonly understood format, Gherkin) it fosters really get the way you work in a very agile way. More on that later. Cucumber is a very well known tool in the Ruby world, where projects often create web applications. I think that this inheritance has influenced the process above, which...
Read More

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 to “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 searching high and low on the net for best practices on how to managing your features through the course of a project. I didn’t find much due a couple of reason: the Ruby/ cucumber inheritance of .net tools such as SpecFlow is great - you...
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 the .NET framework to...
Read More

SpecFlow.exe and MsTest

With your SpecFlow installation comes SpecFlow.exe that is a program that can be used to generate tests from the scenarios AND to create nicely formatted reports from the generated test results. There’s been a lot written on how to generate these reports when your using NUnit (see this and this for example), but when it comes to managing this for MsTest there’s been almost silent. And facing this problem I can sure see why… It’s a bit trickier. In this blog post I want to show you two things; how to generate MsTest’s 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 MsTest’s from your .feature-file With this step you can generate the test from you scenarios. SpecFlow.exe picks up...
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 concepts of tags has been the 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. And the über-cool @wip-tag that allow you to limit the number of items in progress for the team. Yam for Kanban lovers. OK – but when I got around to try it in SpecFlow I was a bit disappointed to learn that the only @ignore was supported… Or was it? @ignore @ignore is in other words the only tag that is 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 that are not ready to be run yet. Custom tags...
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 in a great way....
Read More

The emperor is naked–don’t ask me to estimate!

This is a well known truth for all doing agile method. Introduction I’m doing a migration project right now. My team is great - could be the best I’ve ever worked with. We’re converting a big VB6 application to VB.NET and WPF. And due to different reasons we decided to do this in two phases: First migrate everything with a tool and then get it to work again. And write a integration test that assures that the function works as expected Rewrite the underlying architecture bit by bit. Since we have integration tests in place we are shield from introducing any big bugs. OK, the first phase mean that we worked our way through the old code, form by form. It was 265 of them and we created a simple tracking tool in Excel that classified each form as S, M, L or XL (based on size in KB). As...
Read More

Should & Substitute–two new great friends

Recently I’ve stumbled upon two great framework that greatly enhanced my test code. Should I? Yes – you should First up is Should – which is a assertion framework that makes your assertions much more readable and easier to write. Here’s some code that shows off it’s capabilities: object obj = null; 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".Should().Not.Be.Empty(); "This String".Should().Not.Contain("foobar"); var list = new List<object>(); list.Should().Count.Zero(); list.Should().Not.Contain.Item(new object()); var item = new object(); list.Add(item); list.Should().Not.Be.Empty(); list.Should().Contain.Item(item); One really nice feature is that the framework isn’t tied to any testing framework but works nicely with any test framework. Get me a substitute! Now The other framework is NSubstitute which is a mocking framework. I first got hooked when I read their intro: Mock, stub, fake, spy, test double? Strict or loose? Nah, just substitute for the type you need! I’m probably the...
Read More