Mark Freedman’s Blog |
|
|
Productivity through technology, and other related topics.
|
Between handling response issues, we’ve continued our NUnit exploration.
From what I’ve been reading, it appears that using NUnit without the intention of TDD is like using Visual Studio without enabling Intellisense. Why bother?
I started by reading a few articles, such as Getting started with TDD , by Steve Smith. I also read a good one by Roy Osherove, and he states in his Test-driven development with NUnit - Introduction article, there are three bulletpoints for doing TDD:
Now, that seems rather simple, but the hard part is figuring out what tests to write , and if you’re testing existing code, should you refactor it in order to enable proper testability.
The concept that seems to be hardest for people starting out in TDD to grasp is the whole concept of writing a test that fails even before attempting to write the code that implements the feature being tested. But if you think about it, it’s a pretty common iterative approach to things.
The first example in Roy’s article shows that you do this by trying to instantiate an object from an as-of-yet non-existent class. You can’t get much more basic than this. That’s an easy one to get to pass, and it’s a bit of a high getting that test to turn green. Now you feel like you’re on your way.
We’ve answered our first two questions from the prior article , and decided not to learn by incorporating tests into our existing systems, mainly due to the comment made in my previous article that we need to assume that current systems are "clean".
Due to scheduling conflicts, we also answered question 4 (should we have the team work together on a single system so we can all learn together, etc.). We’re experimenting on our own with samples that come with NUnit, plus our own small examples. As we work on future projects, we’ll build on that by generating tests for new code, and creating tests for modified code. We also recognize that refactoring will probably be in order to make existing code more testable, so we have to be mindful of including this into our estimates. Convincing management shouldn’t be too difficult, since they already feel the pain of too many bugs getting into QA, and are realizing the up-front time investment is worth it.
We’re still discussing question 3, the introduction of mocking. We’re leaning towards building our own mock objects on an as-needed basis at first, and we’ll look at third party mocking tools later on.
We’ve also taken a look at TestDriven.net , which provides some basic integration into Visual Studio. The best part of this tool that we’ve seen so far is the included nCover utility, which helps us to see what code we may have missed writing tests for. The jury is still out for us on the entire TestDriven.net tool, since nCover is available separately, but some people swear by the whole package.
Well, on with my best practices investigation for introducing NUnit and TDD…
Update
I’ve updated some of the points below, based on some of the comments I received, including points about when to answer questions, the appropriateness of jokes, and following through after the presentation.
Last night, I attended a terrific Speaker Idol event at the NYC .NET Developer’s Group at the Microsoft office in NYC. It’s one of the formats I mentioned in my post about user group meeting ideas.
This was the first user group meeting I’ve attended since I helped start a couple, and it was really nice to focus more on learning rather than coordinating. I had three main motivations for attending this meeting:
I feel like I met these goals. First of all, attending these in NYC always gives me a rush of energy. I love going to the city, because it’s so amazingly alive and vibrant. It gives me the feeling of being able to accomplish anything. And there’s nothing like a warm summer night in the city that never sleeps.
And the second and third goals were accomplished with flying colors. Although I tried to make this a non-working event, I couldn’t help myself. I spent the entire night taking copious notes. And although this was the first Speaker Idol event I’ve ever attended, and it’s the only one I can base my observations on, I think it came off great. I think it can serve as a model for future events, so I put together a list of guidelines from this experience.
Although I haven’t presented at user groups yet, I’ve had similar experiences. My tips are a combination of those, of comments from last night’s judges, and of my observations from this and other user group meetings.
Great job done by Stephen Forte, Andrew Brust, Peter Laudati, Bill Zach, and all the speakers and judges!
A Speaker Idol event is similar to a mini code camp, where you’re pretty much going crazy trying to get equipment set up and tested. It was pretty hectic last night, with people downloading codecs, using borrowed laptops, etc. More about this in the Speaker Tips section, below.
Do the three "P"s: Prepare, Practice, and Present. I’m sure I’ve heard that phrase before, but I’m not sure who to credit…
Many people attend these presentation for the educational value, in order to keep up with what’s happening in their field, and they make a significant time commitment to attend your presentation. Whatever your motivation for speaking, the reputation you earn is based upon more than your session. How you follow through also counts in a big way.
I anticipated such an event to be a lot of fun, and it exceeded my expectations. I’m sure it was nerve wracking for the speakers and the moderators, but like my experience with the code camp, I’m sure it was well worth it. I’ll use this post as a guideline for when my group runs a similar event, and hopefully others will find this useful, even though I’m basing it upon limited personal experience. If you have anything to add or suggest, please comment.
My team is taking a dedicated look at NUnit over the next week or so, in order to figure out how to incorporate it into the culture.
I feel sort of guilty spending so much dedicated time on this educational task, because I’m so used to spending my days firefighting, managing, and troubleshooting. But this should be part of an Architect’s job, so I’m trying to ignore this uncalled for guilt emotion.
We have two main motivations for investigating unit testing. One is the desire to decrease the number of bugs found during the QA process. The other is our move towards continuous integration. I’d love to eventually get to TDD, but that’s a longer term goal.
Also, although Visual Studio 2008 has built-in testing in most SKUs (as opposed to what VS 2005 did), we decided to go with the de facto standard of NUnit. Besides, I understand there’s an integration option for VS, anyway.
The initial questions we’ll be looking to answer is the following:
One of the first things I did was google for how others are approaching this problem. I found a lot of articles, so I have a bunch of reading ahead of me.
I’ll be posting links to those, and whatever else I learn, in the upcoming days.
When it comes to estimating, developers live in an idealistic world. Despite repeated experiences of constant interruptions causing projects to overrun estimates, developers tend to look at subsequent projects with wishful thinking.
It’s strange. Most developers associate so much pain with the last minute rush to deadlines, you’d think they’d surely tack time onto their next estimate. Developers absolutely loathe the following required and unavoidable tasks that occur almost every day:
Yet, with so many of these cutting into their daily attempts for focused development, you’d think they’d take these into account when estimating the next project. Developers dream of a world where they could lock themselves alone in a room for days, with coffee and junk food, and just code…
(taking a break to dream… niiice…)
…and nothing will ever kill that dream, no matter the pain of what they’ve just been through. It’s an admirable stubbornness and idealistic mindset, but it just ain’t realistic.
Developers, (developers, developers,) if you can’t convince yourself that you’ll be doing more than coding, for your next estimate pretend that you’re working at least 30% less than a full week. Just pretend you’ll only be working 25 to 30 hours per week. Now how long will it take you to complete the project?
Of course, the next thing to tackle is the complaints about interruptions, even after proper estimates…