|
I've mentioned before that you should try to automate testing wherever possible. There are two main reasons for this
How do I set up testingYou need to follow the same steps for testing classes as for procedural code. I will use procedures here for an example. You have a function called calculate discount that is supposed to take the value of an item and calculate the level of discount applicable.
The function could be set up as Public Function CalcDiscount (Quantity As Long) As Double The Test Cases
I have made a couple of assumptions - such as we are expecting an error for incorrectly formatted data. By preparing the test cases I can check with others that my assumptions hold true to their original intention of the discount rule. Automatic testingOnce we have our test cases planned we can run them. The easiest way to do this is to place them in a text file so that they can be easily added to in the future. We simply read in each case and log the results to a test file for observation.. Public Function CalcDiscount(Quantity As Long)
As Double CalcDiscount = 0.05 'This
is wrong but hey... Download a copy of the test case file Come back next week for more details on how to automatically test all of your functions each night and create a report for you to view in the morning. |
Last updated insert_Date |