Yet Another Use of a Unit Test Framework
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
4: public class WhenTheUserClicksNo
7: public void ThenTheDialogResultShouldBeNo()
9: ConfirmationForm confirmationDialog = new ConfirmationForm();
10: DialogResult result = confirmationDialog.ShowDialog();
12: Assert.AreEqual(result, DialogResult.No);
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.
3 thoughts on “Yet Another Use of a Unit Test Framework”
Great post..thx for sharing your knowledge and especially thx for sharing the link to the post that explains — how to run
unit tests as load tests… A situation that requires that emerged just recently and I was in great need to learn it ASAP..so again a BIG thx for that…
Comments are closed.