Monday, 10 October 2011
Eating the BDD and Agile Cake with SpecFlow - Part 1

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 Smile

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.

Install SpecFlow

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.

posted on Monday, 10 October 2011 12:46:03 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Saturday, 01 October 2011
Solving the 3709 error problem

I've spent many weekends looking into this problem and thought I'd best blog it so some one else at least gets the benefit of it.

The issue I am talking about centres around the following error message.

"The connection cannot be used to perform this operation. It is either closed or invalid in this context."

The above error message has been a true bane to me. It was an issue on a classic ASP site that was quite happily ticking away for many years. I spent ages looking through the code ensuring that the SQL Connection was properly closed after each use and that ADODB.Recordsets were being used correctly. The error didn't make sense to me because the problem only happened occasionally and I was convinced it was either an issue with MDAC or the version of IIS (we had moved to a new server a few months ago) .

The solution
To cut a long story short, the solution I discovered  was in SQL Server 2005! Looking through the SQL server logs I discovered that after the last request SQL Server would "Auto Close" the connection and release resources. When the website made another request SQL would be busy spinning up which would then return the error above!

To stop this happening right click on your database in SQL Server Management Studio, select properties, then select Options and set "Auto Close" to false. I believe this option is now removed in newer versions of SQL Server.


posted on Saturday, 01 October 2011 00:32:33 (GMT Standard Time, UTC+00:00)  #    Comments [0]