As systems accessing databases are a major percentage of developments - has anyone any ideas regarding unit testing this. The problems being - how to practically make a DB return to state after test run, to ensure its in expected state before test run, to test the unit of code interacting with the DB functioned correctly - eg updates to hundreds of records. All this without over burdening the developer.
Thanks - but with unit testing we must ensure that each unit test can be run independently and in any order/combination - so it would need a mechanism to put it back as before after each test is run - usually one after another in a batch. If the mechanism requires complex code adding - then this could cause additional opportunity for errors being introduced into the unit tests.
True.. I would personally create a separate batch job to do the work, and run that each time it was required. If there are errors then they need to be dealt with, but they can be ironed out over time, and the same code can be used for the next system you are testing.
For an Access database the batch job could be a simple .bat file, whereas for 'proper' databases like SQL Server or Oracle it would probably be best as a stored procedure.