The applications architectures should ensure each layer is testable.
One layer in particular requires special attention: the database access layer.
The unit tests for objects in this layer must perform the following operations:
– setup the database content
– execute the code
– execute test validation code.
 
For example, to test an insert:
A.
 – make sure the record does not exist
 – execute the code
 – verify the record has been properly inserted
 
B.
– make sure the record exists
– execute the code
– verify the behaviour (the code may raise an exception or it may simply not execute the insert; the second option
  is more developer-friendly, but it may not be acceptable in all cases; it may also execute slower).
Advertisements