% Option Explicit %> <% Sub Main() Call WriteStandardHeader("Idiot's Guide to Unit Testing", _ "Idiot's Guide to Unit Testing, focusing on ASP/VBScript", _ "Unit Testing, ASP, VBScript, ASP/VBScript") Call UnitTestingGuide() Call WriteStandardFooter() End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' UnitTestingGuide ' ' Purpose: ' ' Displays the guide. ' ' Revisions: ' ' [TDB 03.Apr.2002] Code written. ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub UnitTestingGuide() %>
This is a short guide to Unit Testing based on my experiences of wanting to do it after reading books like Extreme Programming Explained and Thinking in Java
This question has been answered better elsewhere but for me the answer is simple: I want to be able to make changes to code, even code I haven't looked at in a year or two, and then make those changes live with greater confidence that I haven't broken anything than I do currently. On a gut level I reckon there's a 25%+ I break something on code older than 6 months - no amount of good practices and extensive commenting seems able to combat this
Update 8th December 2002 - In actual fact I think that unit testing in ASP 3.0 and VBScript is basically impossible. Unit testing calls for discrete chunks of code that can be called in isolation. The Object-Oriented support in VBScript is weak and even with mock Request and Response objects and well-designed orthogonal routines its still a hack job. But as Microsoft has abandoned all non-OO programming with its .NET strategy its not something we'll have to worry about for long ... I've left the old material below for interests sake ...
At work I mainly use ASP/VBScript, which is where I write most of my applications. I searched for some time for some advice on unit testing in this most Microsofty of environments (the unit testing philosophy now seems inextricably tied with Extreme Programming and, to a lesser extent, Open Source Software) and found little. However, these two sites were both useful:
Owen Rogers, the author of ASPUnit was actually very helpful to me - his sourceforge site actually had the wrong code up but he sent me the right stuff and corrected the site very swiftly when I showed an interest
So that's the theory and the framework dealt with. Now for the tests. Despite reading reams of advice all over the web on how to write unit tests, I've found it singularly difficult. Mainly I think because the philosophy evolved in object-oriented languages like Smalltalk and Java. If you're not writing object-oriented ASP then your testing is liable to come unstuck. Also Functions or Methods that output HTML are not great for writing tests for and that's what about half of my functions do. I think I need to get more granular. More bulletins as events warrant
If you found any particular approach useful or if there's something
you think needs to appear on this page please let me
know at bakert+unittesting@gmail.com