Code Snippet Details

<- Back to List


Language
VBA
Description
VBA Test Module
Code
'======================================================================================================================= ' Module: Test ' Purpose: General Purpose Test Methods called from other Test Modules. '======================================================================================================================= Option Compare Database Option Explicit Public Sub RunAll() Test_SeveranceCalculators.RunAll End Sub Public Sub TestInitialise() Application.SetOption "Error Trapping", 2 ErrorHandler.Clear End Sub Public Sub PrintHeader(testModule As String) PrintHeaderLineLevel1 PrintTestModule testModule PrintTimeStarted PrintHeaderLineLevel2 End Sub Public Sub PrintTrailer() PrintHeaderLineLevel2 Debug.Print "Test Run Completed at: " & Now PrintHeaderLineLevel1 End Sub Public Sub PrintError() With ErrorHandler.ErrorDetails Debug.Print "Error - Number: " & .Number & " Description:" & .Description & " Source:" & .Module & "." & .Method End With End Sub Public Function AreEqual(testName As String, valueName As String, Expected As Variant, actual As Variant) Dim Description As String: Description = testName & " Test.AreEqual:" & " Name:" & valueName If Expected = actual Then Debug.Print "PASS -->" & Description & "- Expected:" & Expected & " Actual:" & actual Else Debug.Print "*FAIL-->" & Description & "- Expected:" & Expected & " Actual:" & actual End If End Function Private Sub PrintHeaderLineLevel1() Debug.Print "==========================================================================================" End Sub Private Sub PrintHeaderLineLevel2() Debug.Print "------------------------------------------------------------------------------------------" End Sub Private Sub PrintTestModule(testModule As String) Debug.Print "Module under test: " & testModule End Sub Private Sub PrintTimeStarted() Debug.Print "Test Run Started at: " & Now End Sub