Monday, May 18, 2009

Introducing ASPUnitRunner

Have code in classic ASP? Want to write unit tests for it? Want to make it easy to run those tests?

Here’s my solution: ASPUnitRunner. It’s a .NET library that enables running ASPUnit tests via NUnit.

The Story

(If you don’t care about the “why”, skip this section.) I’ve been trying to get more into automated testing and TDD. But most of our code is written in classic ASP. I started writing some tests using the ASPUnit unit-testing framework for classic ASP. It does it’s job, but I found there was a little friction running the tests. You have to open a web browser, navigate to the right location and click Run Tests. And, continuous integration frameworks don’t exactly have out-of-the-box support for ASPUnit.

There are multiple options available: create an application shortcut for Google Chrome, write a script that uses cURL or wget, or setup Selenium or Watir tests like @calvinb. Any of these may work for you, but none of them were quite what I wanted.

I also found a refreshingly new series of posts on unit-testing classic ASP by Justin Davies. (You should really check them out if you’re interested in unit-testing classic ASP.) I had had the idea in my head to automate ASPUnit tests with NUnit, but he had already done it (albeit with his own unit testing framework). His articles inspired me and gave me some ideas, but it wasn’t until now that I actually wrote my own.

So I wrote my own library to allow running tests for the existing ASPUnit framework from the popular and easy-to-use NUnit test runner.

An Overview

ASPUnitRunner consists of two main classes: Runner and Results.

Runner’s constructor takes a URI to your ASPUnit test runner and an optional credentials parameter. You then call the Run method with the name of the ASPUnit test container to execute, which returns a Results object.

The Results object has the following properties: Tests, Errors, Failures and Details. You can use NUnit assertions to verify that there are zero errors and zero failures and display details if there were any errors or failures.

The source is available at github. If you come up with any improvements, let me know and I may integrate them.

How to Use

Note: the following instructions assume you have existing, runnable ASPUnit tests and are familiar with Visual Studio and NUnit.

  1. Verify that you are able to run your existing ASPUnit tests from a web browser.
  2. Create a new NUnit test project in Visual Studio.
  3. Download the latest ASPUnitRunner binaries and extract them.
  4. Add a new reference from your Visual Studio project to point to the DLL you just extracted in the last step.
  5. Create an NUnit test fixture similar to this example (note that it makes use of the Values attribute new to NUnit 2.5).
    • Add a using AspUnitFramework statement
    • Initialize a new Runner object with the URI for your ASPUnit test runner and optional credentials
    • Run the tests for each desired ASPUnit test container
    • Assert that the results has no Errors and no Failures.
  6. Compile
  7. Run the new tests using your favorite NUnit test runner (or integrate them into your NUnit-compatible continuous integration server).


Unfortunately the NUnit GUI does not format the HTML result details well. I would like to improve this in the future.

I make no guarantees that this library won’t open a black hole and suck up your computer and the rest of the universe, nor that it won’t cause any other type of damage or loss.


ASPUnitRunner is not actually dependent on NUnit. It should be usable from any .NET test framework.

In Conclusion

Other than some scripts and snippets, this is my first publicly released project of my own. Sure, it’s really small and simple—but it’s something.

Thanks to the creators of ASPUnit and NUnit for creating helpful tools and Justin Davies for the inspiring example.

I would love to hear any suggestions or feedback you have. Let me know if you find this useful. If you have questions getting it to work I’ll try to help as I can, but no guarantees.

Sunday, May 10, 2009

Thoughts on development and life

I tend to be a perfectionist. I can easily get into analysis paralysis trying to figure out the ideal approach to a problem.

The idea of TDD appeals to me because it is supposed to enable rapid progress while proving the code does what it’s supposed to. You keep it simple and quick by doing the simplest thing to get it to pass the test. Once it passes the test you get to refactor to clean up the code and you know it still works if it passes all the tests. Then you write the next test.

Sounds lovely. Wish I was there. I’m not, but I’m trying to head that direction.

I’ve found that writing tests can be hard. Particularly dealing with GUIs, database access, legacy code and deadlines.

Most of our codebase is in classic ASP with few tests. I’ve written a few tests using ASPUnit, but running tests from a web browser isn’t my favorite. So I just wrote a .NET library that enables running ASPUnit tests from NUnit. (I’ll share details of that in a future post.)

I feel like I’ve learned so much over the past year. I also feel like there is so much more I still need to learn and so much room for improvement. I actually get pretty frustrated by my slow progress at times and how much I still have to learn.

I had a season where I spent a lot of time reading technical books and articles and programming and I’ve been attending user group meetings, but I let other areas of my life suffer. Then God readjusted my focus. As much as I love programming, it is not my source of joy. Jesus is.

So I’ve been adjusting my priorities and trying to put God first. But I still program at work. And I want to grow as a developer and become excellent in my craft. So now I’m trying to find the balance, where I keep God first and don’t neglect important things like sleep and friendships while still growing as a developer.

Anyways, those are my thoughts. It may or may not make sense to you, but if you have any feedback feel free to leave a comment. I think I’m gonna go hike for a bit now.

Tuesday, May 05, 2009

Navigating the Maze

I’ve been meaning to write this article for a while. Here’s the reason behind my blog’s title.

maze A maze

When I was a kid someone built a human labyrinth in my hometown. It was called The WOOZ (photo). While it got old after a few visits, I do have some fond memories of finding my way around the maze trying to get stamps from each of the four towers and reach the finish line in time to do the bonus challenge.

My life feels like a maze a lot of times. A much bigger, more complicated and more mysterious maze than the WOOZ ever was. But a maze nonetheless. And I’m in it. And I spend my life going through it.

I’ve even received a couple prophecies that refer to my life feeling like a maze or like finding my way along a narrow path.

Sometimes I try to figure this maze out on my own and I’ve wasted time getting really lost.

But it’s not a maze I can successfully navigate on my own. I can’t see very far and I don’t know where to turn. But I’m learning to wait on God and let Him lead me. Because He does know the way through this maze.

Sometimes, I get a glimpse of what’s ahead, like a tower in the WOOZ. But who knows if the next turn will lead to the tower entrance or if I will have to go through several more twists and turns to get to it. Some destinations I will never get to and others seem to come out of nowhere. That is a maze. That is life.

For example, working with computers was something I saw from far off. But going to UC Berkeley and moving to Nashville were two things that happened with little forewarning. There are other things I thought would’ve happened by now, but I’m still waiting.

There have been some tough roads. But there have also been some really amazing moments. Learning to trust God has rarely been easy. But to know that Jesus is walking with me, that He is leading me and realizing more and more how much He loves me makes this journey worth it.

Your word is a lamp to guide my feet and a light for my path. – Psalm 119:105