Types Of Tests

What kind of tests should be incorporated into the unit tests?  Here is one example:

Assume that OutputRecords is a method that formats and outputs data records to a report file and GetRecords is the method that returns a recordset with the required data.  Tests should be written to handle the following cases:

1. 0 records.
2. 1 record.
3. 2 records.
4. A few records – an arbitrary small number of records somewhere between 3 and 10 for example.
5. N-1 records, where N is the number of records on a page.
6. N records, where N is the number of records on a page.
7. N+1 records, where N is the number of records on a page.
8. 2N-1 records, where N is the number of records on a page.
9. 2N records, where N is the number of records on a page.
10.2N+1 records, where N is the number of records on a page.
11.X records, where X is an arbitrarily large number of records.

Even though there are 11 cases here, there is no reason why 11 subtests could not be incorporated into a single test.  The code to perform each of these 11 tests could easily be put into a loop.  Of course, the developer should use his best judgement on when and how to do this.

 

Prev          Next          Back to write the unit tests

Copyright 2011 by Robert G. Bryan

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s