Yet Another Use of a Unit Test Framework

Yet Another Use of a Unit Test Framework

Posted by David Starr | November 26, 2008 | Unit Testing

Believe me, I understand TDD. I grok it. It is in my soul.

I also happen to believe (and know from experience) that unit test frameworks are valuable far beyond their use in TDD. Some of the best uses are for integration tests at the API level.

It is this coolness that makes it so handy to run a unit test harness as a load test run using VSTS. I worked with one client who had a particular need for this in testing a HUGE network of independently addressable embedded Linux devices, each one exposing a TCP/IP-level API. More on how to running unit tests as load tests here.

But on to my latest use of a unit test. Remember back in the day when we wrote libraries without unit test frameworks? What did we do? We wrote a little command line EXE to exercise the thing while we wrote it and never checked that in to SCC. It worked, mostly.

I often have the same need when writing Windows Forms applications. I want to spool up and play with a window without all of the overhead of the entire application. So, here’s my test.

   1: namespace ElegantCode.BeSure.Test.GivenTheConfirmationDialogIsDisplayed
   2: {
   3:     [TestClass]
   4:     public class WhenTheUserClicksNo
   5:     {
   6:         [TestMethod]
   7:         public void ThenTheDialogResultShouldBeNo()
   8:         {
   9:             ConfirmationForm confirmationDialog = new ConfirmationForm();
  10:             DialogResult result = confirmationDialog.ShowDialog();
  12:             Assert.AreEqual(result, DialogResult.No);
  13:         }
  14:     }
  15: }

No, this is not a unit test. All this does for me is allow me to open the window in a run time environment, see it lay out on the screen, click around on it, etc.

If you notice the structure of the test naming, I am using a little BDD convention because I am wondering about the idea of building a manual regression suite this way. What if a tester sites down and runs through a manual test by launching the a unit test harness that drives the UI.

It’s an interesting idea, anyway.

Related Blogs

Posted by Simon Reindl | April 30, 2012
Running nUnit in a TFS11 build on 64 bit server
Overview In TFS/VS 11, frameworks other than MS Test are supported, which is cool. Peter Provost mentions them here. OK, so you start to use this great new feature, queue...
Posted by Simon Reindl | December 10, 2010
Top 5 Reasons to use VS Database Projects
There is a traditional resistance to using database projects – the production system is the reference point, and I have a backup, so what is the problem, right? Since the...
Posted by Martin Danner | March 10, 2009
Team Foundation Adapters Project
I'm pleased to announce that the Team Foundation Adapters project is up and running on CodePlex. The project description is as follows: Team Foundation Adapters make it easier to do...