Objective: To ensure that each member in the CStockList and CStockItem classes have been run at least once to ensure correct behavior. This is a component-level test that will be performed by the development team.
Test methodology: The two classes are implemented in an ActiveX DLL. This allows for the creation of a dedicated test harness application that will act as a normal client program. For this initial test, sample data will be hard-coded into the test harness application. (The possibility exists to extend this in the future so that test data will be read from a data file.)
Scope of this strategy: This is a generic document that outlines a method of testing without providing any test data. Reasonable test data can be created as required.
Test environment: Windows 98 (full installation), run-time files as installed by Visual Basic 6. No service packs are applied to these products at this time.
SERVERDATA.DLL test 1
Members used: Add, Count, Item, StockValue
Intent: Check that a record is added successfully.
- Formulate the data for a new record that doesn't already exist in the table.
- Create a reference to a CStockList object.
- Call the Item method using the new StockCode value (from step 1) and verify that this raises a "not found" error. This is to check that the record doesn't already exist. If it does exist, this test data has already been used and so the rest of the test should be aborted.
- Call the Count property. Check that this tallies with the number of records currently in the table (via Access?).
- Call the StockValue property to establish the value Y of total stock currently held.
- Calculate the value X of the new item of stock that is to be added by multiplying the StockLevel value with the UnitPrice value.
- Call the Add method with the new stock data.
- Call the StockValue property and verify that it is equal to the value of X + Y.
- Call the Item function to obtain a reference to a CStockItem object. Verify that each property matches the original data. Release the reference to the CStockItem object.
- Release the reference to the CStockList object.
SERVERDATA.DLL test 2
Members used: Add
Intent: Prove that a new record with a duplicate key value will be rejected.
- Create a reference to a CStockList object.
- Attempt to add a record that already exists. A predictable error should be raised (that is, client error handler should include a check for this specific error code being raised).
- Release the reference to the CStockList object.
SERVERDATA.DLL test 3
Members used: Remove
Intent: Check that an attempt to delete a record that doesn't exist will fail gracefully.
- Create a reference to a CStockList object.
- Attempt to remove a record that doesn't exist. A predictable error should be raised.
- Release the reference to the CStockList object.
SERVERDATA.DLL test 4
Members used: Item, Update
Intent: Prove that the CStockItem.Update method will reject an attempt to modify a record where the StockCode value would be the same as an existing record.
- Create a reference to a CStockList object.
- Attempt to rename a StockCode value to an existing value. A predictable error should be raised.
- Release the reference to the CStockList object.