Theory of Constraints and Specification by Example

Since I first encountered Specification by Example (or BDD as it’s also known), I felt it had a natural alignment with Lean thinking and related theories. Today, I want to explore how the Theory of Constraints can be applied through Specification by Example to enhance the system development process.

Standing on the Shoulders of Giants

This post reflects my own thoughts and tries to piece together insights from various experts. I owe much to pioneers like Dan North, Eliyahu Goldratt, and Gojko Adzic, among others.

Theory of Constraints

Last year, I read the insightful book, The Goal by Eliyahu Goldratt. Goldratt’s Theory of Constraints (TOC) asserts that every system has at least one bottleneck that limits its overall performance. Improvements to other areas are less effective if they don’t address the bottleneck.

Here’s a simple example:

Imagine Marcusoft Welded Steelplates,...

Read More

Clean up your steps–use page objects in SpecFlow step definitions

If you are a developer doing BDD, as me, you’ll soon run into the joys of UI automation. The BDD community today seems to lean towards running your specifications/test end-to-end in order to capture the whole stack of the application as well as getting great regression tests.

But tests against the GUI can be brittle, that part of the application is the one that most often is changed, in my experience. So writing automated stuff (in essence programs) against a changing environment is not very pleasant as you might well know.

This post is about using the Page Object pattern that can help you handle this brittleness as well as structuring your test code in a nice, maintainable way. That in turn will help us to place code in the right place – which I like. Some guidelines, if you like.

Inspiration

I have of course not invented...

Read More

Two Types in SpecFlow - ScenarioContext and FeatureContext

Recently, I had the chance to explore more advanced error handling with SpecFlow and delved into the ScenarioContext and FeatureContext objects. These components offer some powerful capabilities that are worth understanding. In this post, I’ll take a closer look at both and offer some tips on how to utilize them effectively in your SpecFlow projects.

ScenarioContext

Most of us have encountered the ScenarioContext in the code generated by SpecFlow when a step definition is missing:

[Binding] public class StepDefinitions { [Then(@"I don't have this step definition in place yet")] public void ThenIDonTHaveThisStepDefintionInPlaceYet() { ScenarioContext.Current.Pending(); } } 

However, ScenarioContext provides several other useful features:

ScenarioContext.Pending

The Pending method is well-known for marking steps as pending when...

Read More

KanbanBoards VI–OpenId Integration

It’s been a while since I did any work on the KanbanBoards project, but now I got around to add some more features. I planning on doing some acceptance tests for creating new boards. The controller functionality was spec’d out in then last installment of the series.

To do that properly I need to touch on two main areas of functionality:

  • Authentication – here I plan to use OpenID and see if I can plug-in some functionality that already exists.
  • Uploading pictures – just for fun I will try to store the pictures in the database and see how that sits. I can already here give away the fact that I didn’t do this today.

And finally show that the whole thing works using an acceptance test that verifies the functionality end-to-end.

Let’s go.

Feedback and updates

I got some great feedback from some people,...

Read More

Specification by Example with SpecLog – Some Initial Thoughts

I have been talking about BDD or specification by example almost every day for a year and a half now. I still love the idea—executable specifications that everyone concerned can read, so you can talk about the behavior of the system before a single line of code is written. Yeah, you see, as soon as I start to write about it, it’s hard to stop.

Most people (or roles rather) react positively to this idea; developers love the possibility to get a detailed specification to start from, testers see great promises in automating the tests, and requirements people love the traceability features and the level of detail that you get before you start.

It’s the workflow or process that is the “problem.” How do we organize the work around this? Who writes those features? Where are they updated? I have blogged about this several times before, but...

Read More

SpecFlow presentation at Sweden Progressive .NET

I got an invitation to the Sweden Progressive .NET (the group formerly known as Alt.Net Sweden) to do a presentation on SpecFlow. I know many of the people in this group, a lot of them work for Avega, and have the highest respect for their knowledge.

So to get an invite from them to talk about a BDD tool was really cool, and a bit nerve-wracking. But it also made me step up my game and I put quite a lot of time into creating a demonstration project that shows the different features of SpecFlow and how to use them effectively.

Of course, I created features for them so that you can easily read and understand them without even having to look at code. This was inspired by how TechTalk themselves spec out new features of SpecFlow and proved to work very well. I plan to update them as new...

Read More

Error Provider Did Not Return

--- layout: post title: Error “The provider did not return a ProviderManifestToken string” with SQL Compact Edition date: 2011-02-16T12:51:00.001Z author: Marcus Hammarberg tags: - .NET - SpecFlow modified_time: 2011-02-16T13:34:46.482Z blogger_id: tag:blogger.com,1999:blog-36533086.post-6161852859030600182 blogger_orig_url: http://www.marcusoft.net/2011/02/error-provider-did-not-return.html --- I was totally terrified when this happened to my yesterday. I had prepared a little website to use on a [SpecFlow](http://www.specflow.org) demonstration. I had run it several times and it worked fine. But all of a sudden – when I was doing one of those “just checking” it failed on me with this (“The provider did not return a ProviderManifestToken string”) error. The site was using Entity Framework Code first with [SQL CE as described here

      Read More
    

In SpecFlow the test runner is just glue

I answered a question on Twitter today from a guy who had problems running SpecFlow scenarios with MSTest. That shouldn’t be I thought to myself – in SpecFlow the test runner is only used for the auto-generated stuff (#2 in this pictures) and shouldn’t affect the code you write. Lets try it.

The default test runner is NUnit so first I simply create a new Specs-project and created the following scenario:

stupid steps in scenario

I then Nuget’d SpecFlow, Should and NUnit with these commands:

Install-Package SpecFlow Install-Package NUnit Install-Package ShouldFluent 

And sure enough – when I compile some NUnit code is auto generated for me:

generated nunit code

Just for good manners I implemented the steps and ran the specification. It worked with these (naïve) steps in place:

naive steps

If I now change...

Read More

Kanbanboards V–creating new boards

OK – after the last post of refactoring I now feels great to turn my focus on some new functionality; I want to let the users create new Kanban boards. This involves some new views and controllers stuff, uploading pictures and also changes in the domain model.

I got some valuable feedback from my colleague Joakim Sunden on the real purpose of the Kanban board application / site. I actually never wrote it down. So I’ve updated the first post in the series with the following:

www.kanban-boards.com will be a site where users can upload their Kanban boards for other people to see, vote on and get inspired by. In this way we can share and learn from each other I think and hope. The creation of this site is documented as my learning process.

On with the show!

New functionality – new scenario

...
Read More

Customize your SpecFlow templates and more

I got this tip from a non-developer. An intern, actually. He’s brilliant though and figured this out by himself, about 3 months after I introduced him to SpecFlow. Thank you, Dejen – you’re great!

The fact that this is not documented anywhere just adds to the coolness, but also makes the solution a bit hackish. Sorry for that.

SpecFlow stores templates for the feature files in this folder:

C:\Program Files (x86)\TechTalk\SpecFlow\ItemTemplates\ 

I’m using a 64-bit system, so your path may not contain the (x86) part.

Here, you’ll find several zip archives containing the templates. You can modify the EventDefinition, StepDefinition, and (maybe most commonly) the Feature template. All the structure is the same, so you can follow it in the same manner as described below.

How to Modify the Feature Template

  1. Make a copy of the current template (SpecFlowFeature.zip) to...
Read More