Showing posts with label TDD. Show all posts
Showing posts with label TDD. Show all posts

Thursday, May 12, 2011

XQuery Katas

After having several MarkLogic projects back-to-back, I haven't had a new one in far too long. So, to practice my XQuery in the hopes of having a new one soon, I've started a collection of XQuery katas.

The intent of these is less TDD and more brushing up on XQuery, but I'm also interested in testing my functions. To that end you'll see I have my tests built using:
  1. Visual Studio
  2. NUnit
  3. Saxon HE
Meager, but it suits my current needs.

My first kata is up now on BitBucket and I've gotten some constructive feedback from the xquery-talk mailing list. I hope to add more over the next few weeks.

Wednesday, November 24, 2010

Writing Unit Tests Makes Me Feel Stupid

Writing unit tests makes me feel stupid.

Allow me to explain.

I'm not talking about full-blown TDD, but simply about a beginner trying to write some tests in order to make sure code is working as expected in as many cases as possible. What I almost invariably run up against is my own questionable design choices that usually boil down to three issues: lots of dependencies, needing non-trivial data for a meaningful test, or needing a full ASP.NET web request for a meaningful test.

Sure, some classes are small and simple and will have clear tests supporting them. A few more classes will interact with those first ones clearly and cleanly, too. That'll be about ½ of 1% of my total system. While trying to write tests for the rest of the code I'll be mumbling
"How the heck am I going to test that?"

"Ugh. I need to inject that into that into that just to test one method."

"Why would I write it like this? Was I in that much of a rush?"
The more I think about testing my own code on current projects, the more I understand the usefulness of TDD and that the goal is not simply tests but an easily consumable, testable design. I've read Pragmatic Unit Testing for a baseline. Hopefully The Art of Unit Testing and Clean Code will help me avoid painting myself into these corners in the future. In the meantime, I've been watching James Shore's Let's Play TDD series, which is really cool because you're essentially looking over his shoulder as he works on a small app.

I've started to wonder if other people feel the same way and if they avoid testing because of it or if they realize that it's a learning opportunity.