Vb Unit Test Data ManagementSome of the things we could do for VbUnitTestDataManagement, need to be do differently in VbUnitThree
Suite Level Setup and Teardown
Sometimes before we run our tests we need to perform quite heavy operations like resetting the database. We don’t want to do this before every fixture, or even every suit. By designing our tests to leave the database in the same state as they started we can reset the database once each test session, however if a test fails, the database need resetting before we start testing again.
Using VbUnit2 I was able to put setup and tear down functionality in the testrunner exe project.
Public Sub Main()
Dim oTestRunner As TestRunner
Dim oClient As ISuite
SetupTestData
CopyInTestData
On Error GoTo RestoreData:
Set oTestRunner = New TestRunner
'this is the only line that will have to be adjusted to use the runner for other projects
Set oClient = CreateObject("CookingUnit.CookingTestSuite")
oTestRunner.AddSuite oClient
Set oClient = CreateObject("WashingUnitTest.WashingTestSuite")
oTestRunner.AddSuite oClient
Set oClient = CreateObject("DryingUnit.DryingSuite")
oTestRunner.AddSuite oClient
Set oClient = CreateObject("ChoppingUnit.ChoppingSuite")
oTestRunner.AddSuite oClient
oTestRunner.Run True, False
RestoreData:
SaveResults
RestoreSavedData
End Sub
In VbUnitThree we no longer need to write the test runner, which is nice, but it means we can no longer set test data as we could above.
Bodo was good enough to show us how to do this, and the example can be found in the FAQ at http://www.vbunit.org
EditText of this page
(last edited September 14, 2001)
or FindPage with title or text search