Speaking to a colleague of mine one evening, we got talking about Agile and BDD. What I found interesting was that he was providing the Agile aspect for me and I was approaching it from the developers context. I realised that in many of the implementations of BDD I hadn't quite seen the connection happen from the user stories down to the actual BDD tests. While I had seen BDD used I wasn't quite sure it was being done "properly" or working properly it seemed as though lip service was being paid to the methodology. He made the clever suggestion that maybe we should test it out.
"As in make an actual app for the purpose of testing the process?" I said, he nodded and I decided then I was hooked on the idea. I could probably blog about it and let people know about my experience using a test project and it would give me a chance to try out SpecFlow. I would expect to write roughly 3 blog articles covering the subject, feel free to comment on any aspect - all constructive criticism welcome
So getting to the project. We agreed he would be the product owner and I would be the developer (naturally). He went away for a day and came back to me with the requirements for a basket application. He provided me with a user story and then some conditions of acceptance. I looked over his conditions of acceptance and made some more suggestions. We were essentially collaborating around the conditions of acceptance and wording them in the classic BDD syntax. This was good, this was what was supposed to have happened.
The app was to be a simple shopping basket you add products to. My initial reaction was to get coding the basket and I had to quickly stop myself as I realised I wasn't following the process. Do the tests first!
So my Project Setup was as follows. I won't dwindle too much around the SpecFlow setup as I am sure there are plenty of tutorials out there.
Create an MVC project in Visual Studio 2010 and allow it to create an accompanying test project (we will use this later).
Change the app.config of the test project so SpecFlow will work with MSTest (and Resharper)
Step 1. Creating my feature using SpecFlow (in Gherkin). The features file type is available to you in Visual Studio after installing SpecFlow.
Step 2. Run my tests using Resharper and MSTest, as expected my tests fail and SpecFlow gives me recommendations on what it was expecting.
Step 3. Create a Step file for my actual tests (this is where the actual tests are coded in MSTest)
Step 4: I copy the suggested code from SpecFlow unit test in step 2 into my new Steps file
Step 5: I then rerun my tests and get a different error telling me that I basically have empty tests.
Step 6: I am now ready to start coding to fix my tests! Which I will cover in my next article.