Skip to content

Commit 239095e

Browse files
authored
35 output test result to external source database text file xml json (#36)
* Refactoring AccUnitLoader: Replace DebugPrintTestResultCollector with a collector for more ResultReporter (Debug.Print, Textfile, XML, ...) * output to log file
1 parent 92eb0de commit 239095e

File tree

66 files changed

+1281
-760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1281
-760
lines changed

access-add-in/AccUnitLoader.accda

-152 KB
Binary file not shown.

access-add-in/source/forms/AccUnitLoaderForm.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Attribute VB_Exposed = False
1717
'</codelib>
1818
'---------------------------------------------------------------------------------------
1919
'
20-
Option Compare Database
20+
Option Compare Text
2121
Option Explicit
2222

2323
' verwendete Erweiterungen

access-add-in/source/forms/AccUnitUserSettings.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Attribute VB_Exposed = False
1616
'</codelib>
1717
'---------------------------------------------------------------------------------------
1818
'
19-
Option Compare Database
19+
Option Compare Text
2020
Option Explicit
2121

2222
Private m_UserSettings As AccUnit.IUserSettings

access-add-in/source/modules/ACLibConfiguration.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Attribute VB_Description = "Konfigurationseinstellungen der CodeLib verwalten"
3232
'</codelib>
3333
'---------------------------------------------------------------------------------------
3434
'
35-
Option Compare Database
35+
Option Compare Text
3636
Option Explicit
3737

3838
Private m_DaoSqlTools As SqlTools

access-add-in/source/modules/AccUnitConfiguration.cls

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,13 @@ Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = False
1010
Attribute VB_Description = "Konfigurationseinstellungen der CodeLib verwalten"
1111
'---------------------------------------------------------------------------------------
12-
' Klassenmodul: AccUnitConfiguration
13-
'---------------------------------------------------------------------------------------
14-
'/**
15-
' <summary>
16-
' Konfigurationseinstellungen verwalten
17-
' </summary>
18-
' <remarks>
19-
' </remarks>
20-
'\ingroup addins_shared
21-
'**/
22-
'---------------------------------------------------------------------------------------
23-
'<codelib>
24-
' <file>%AppFolder%/source/AccUnitConfiguration.cls</file>
25-
' <use>base/ApplicationHandler.cls</use>
26-
' <use>data/SqlTools.bas</use>
27-
' <use>file/FileTools.bas</use>
28-
' <use>data/dao/modDAO_Tools.bas</use>
29-
' <ref><name>DAO</name><major>5</major><minor>0</minor><guid>{00025E01-0000-0000-C000-000000000046}</guid></ref>
30-
'</codelib>
12+
' Class: AccUnitConfiguration
3113
'---------------------------------------------------------------------------------------
3214
'
33-
Option Compare Database
15+
' AccUnit configuration
16+
'
17+
'---------------------------------------------------------------------------------------
18+
Option Compare Text
3419
Option Explicit
3520

3621
Private m_DaoSqlTools As SqlTools

access-add-in/source/modules/AccUnitLoaderConfigProcedures.bas

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Option Explicit
33
Option Compare Text
44

5+
' Integrierte Erweiterungen
6+
Private Const EXTENSION_KEY_AccUnitConfiguration As String = "AccUnitConfiguration"
7+
8+
Public Property Get CurrentAccUnitConfiguration() As AccUnitConfiguration
9+
Set CurrentAccUnitConfiguration = CurrentApplication.Extensions(EXTENSION_KEY_AccUnitConfiguration)
10+
End Property
11+
512
Public Sub AddAccUnitTlbReference()
613
RemoveAccUnitTlbReference
714
CurrentVbProject.References.AddFromFile CurrentAccUnitConfiguration.AccUnitDllPath & "\AccessCodeLib.AccUnit.tlb"
@@ -97,18 +104,141 @@ Public Sub ExportTestClasses()
97104

98105
End Sub
99106

100-
Public Sub RemoveTestEnvironment(ByVal RemoveTestModules As Boolean)
107+
Public Sub RemoveTestEnvironment(ByVal RemoveTestModules As Boolean, Optional ByVal SaveTestModules As Boolean = True)
101108

102109
Dim Configurator As AccUnit.Configurator
103110

104111
With New AccUnitLoaderFactory
105112
Set Configurator = .Configurator
106113
End With
107114

108-
Configurator.RemoveTestEnvironment RemoveTestModules, , CurrentVbProject
115+
Configurator.RemoveTestEnvironment RemoveTestModules, SaveTestModules, CurrentVbProject
109116
Set Configurator = Nothing
110117

111118
On Error Resume Next
112119
Application.RunCommand acCmdCompileAndSaveAllModules
113120

114121
End Sub
122+
123+
124+
Public Property Get AccUnitFileNames() As Variant()
125+
126+
AccUnitFileNames = Array( _
127+
ACCUNIT_TYPELIB_FILE, _
128+
ACCUNIT_DLL_FILE, _
129+
"AccessCodeLib.Common.Tools.dll", _
130+
"AccessCodeLib.Common.VBIDETools.dll", _
131+
"AccessCodeLib.Common.VBIDETools.XmlSerializers.dll", _
132+
"Microsoft.Vbe.Interop.dll")
133+
' "Interop.VBA.dll"
134+
End Property
135+
136+
Public Sub ExportAccUnitFiles(Optional ByVal lBit As Long = 0)
137+
138+
Dim accFileName As Variant
139+
Dim sBit As String
140+
Dim DllPath As String
141+
142+
On Error GoTo HandleErr
143+
144+
If lBit = 0 Then
145+
lBit = GetCurrentAccessBitSystem
146+
End If
147+
148+
sBit = CStr(lBit)
149+
DllPath = CurrentAccUnitConfiguration.AccUnitDllPath
150+
151+
With CurrentApplication.Extensions("AppFile")
152+
For Each accFileName In AccUnitFileNames
153+
.CreateAppFile accFileName, DllPath & accFileName, "BitInfo", sBit
154+
Next
155+
End With
156+
157+
ExitHere:
158+
Exit Sub
159+
160+
HandleErr:
161+
If accFileName = "AccessCodeLib.AccUnit.tlb" Then
162+
Resume Next
163+
End If
164+
Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext
165+
166+
End Sub
167+
168+
Public Sub ImportAccUnitFiles(Optional ByVal lBit As Long = 0)
169+
170+
Dim accFileName As Variant
171+
Dim sBit As String
172+
Dim DllPath As String
173+
174+
If lBit = 0 Then
175+
lBit = GetCurrentAccessBitSystem
176+
End If
177+
178+
sBit = CStr(lBit)
179+
DllPath = CurrentAccUnitConfiguration.AccUnitDllPath
180+
181+
If lBit = 32 Then
182+
DllPath = Replace(DllPath, "x64", "x86")
183+
ElseIf lBit = 64 Then
184+
DllPath = Replace(DllPath, "x86", "x64")
185+
End If
186+
187+
With CurrentApplication.Extensions("AppFile")
188+
For Each accFileName In AccUnitFileNames
189+
.SaveAppFile accFileName, DllPath & accFileName, True, , , "BitInfo", sBit
190+
Next
191+
End With
192+
193+
End Sub
194+
195+
Public Function GetCurrentAccessBitSystem() As Long
196+
197+
#If VBA7 Then
198+
#If Win64 Then
199+
GetCurrentAccessBitSystem = 64
200+
#Else
201+
GetCurrentAccessBitSystem = 32
202+
#End If
203+
#Else
204+
GetCurrentAccessBitSystem = 32
205+
#End If
206+
207+
End Function
208+
209+
Public Function AutomatedTestRun() As Boolean
210+
211+
Dim Success As Boolean
212+
Dim TestSummary As AccUnit.ITestSummary
213+
Dim FailedMessage As String
214+
215+
AddAccUnitTlbReference
216+
InsertFactoryModule
217+
ImportTestClasses
218+
219+
SetFocusToImmediateWindow
220+
221+
Set TestSummary = GetAccUnitFactory.TestSuite(LogFile + DebugPrint).AddFromVBProject.Run.Summary
222+
Success = TestSummary.Success
223+
224+
RemoveTestEnvironment True
225+
226+
If Not Success Then
227+
FailedMessage = TestSummary.Failed & " of " & TestSummary.Total & " Tests failed"
228+
Err.Raise vbObjectError + 12, "AccUnitLoader.AutomatedTestRun", FailedMessage
229+
End If
230+
231+
End Function
232+
233+
Private Sub SetFocusToImmediateWindow()
234+
Dim VbeWin As VBIDE.Window
235+
For Each VbeWin In Application.VBE.Windows
236+
If VbeWin.Type = vbext_wt_Immediate Then
237+
If Not VbeWin.Visible Then
238+
VbeWin.Visible = True
239+
End If
240+
VbeWin.SetFocus
241+
Exit Sub
242+
End If
243+
Next
244+
End Sub

access-add-in/source/modules/AccUnitLoaderFactory.cls

Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@ Attribute VB_Creatable = False
88
Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = True
1010
'---------------------------------------------------------------------------------------
11-
' Klassenmodul: AccUnitLoaderFactory
11+
' Class: AccUnitLoaderFactory
1212
'---------------------------------------------------------------------------------------
13-
'/**
14-
' <summary>
15-
' Factory-Klasse für AccUnit
16-
' </summary>
17-
' <remarks>
18-
' </remarks>
19-
'\ingroup addins_shared
20-
'**/
13+
'
14+
' Factory for AccUnit elements
15+
'
2116
'---------------------------------------------------------------------------------------
22-
'<codelib>
23-
' <file>%AppFolder%/source/AccUnitLoaderFactory.cls</file>
24-
' <license>_codelib/license.bas</license>
25-
'</codelib>
26-
'---
27-
Option Compare Database
17+
Option Compare Text
2818
Option Explicit
2919

3020
Private m_AccUnitFactory As Object
@@ -47,7 +37,7 @@ On Error Resume Next
4737

4838
End Sub
4939

50-
Public Property Get AccUnitFactory() As AccUnit.AccUnitFactory
40+
Private Property Get AccUnitFactory() As AccUnit.AccUnitFactory
5141
If m_AccUnitFactory Is Nothing Then
5242
InitAccUnitFactory
5343
End If
@@ -81,20 +71,7 @@ Public Property Get ConstraintBuilder() As Object ' AccUnit.ConstraintBuilder
8171
Set ConstraintBuilder = AccUnitFactory.ConstraintBuilder
8272
End Property
8373

84-
Public Function NewDebugPrintMatchResultCollector(Optional ByVal ShowPassedText As Boolean = False, Optional ByVal UseRaiseErrorForFailedMatch As Boolean = True) As DebugPrintMatchResultCollector
85-
86-
With New DebugPrintMatchResultCollector
87-
.Init ShowPassedText, UseRaiseErrorForFailedMatch
88-
Set NewDebugPrintMatchResultCollector = .This
89-
End With
90-
91-
End Function
92-
93-
Public Function NewDebugPrintTestResultCollector() As DebugPrintTestResultCollector
94-
Set NewDebugPrintTestResultCollector = New DebugPrintTestResultCollector
95-
End Function
96-
97-
Public Property Get TestRunner() As Object 'AccUnit.TestRunner
74+
Private Property Get TestRunner() As Object 'AccUnit.TestRunner
9875

9976
SetErrorTrappingToBreakOnUnhandledErrors
10077
Set TestRunner = AccUnitFactory.TestRunner(CurrentVbProject)
@@ -114,35 +91,10 @@ Private Sub SetErrorTrappingToBreakOnUnhandledErrors()
11491

11592
End Sub
11693

117-
Public Sub RunTest(ByVal testClassInstance As Object, Optional ByVal MethodName As String = "*", Optional ByVal PrintSummary As Boolean = True, Optional ByVal TestResultCollector As Object)
118-
119-
If PrintSummary And TestResultCollector Is Nothing Then
120-
Set TestResultCollector = New DebugPrintTestResultCollector
121-
End If
122-
123-
TestRunner.Run testClassInstance, MethodName, TestResultCollector
124-
125-
If PrintSummary Then
126-
TestResultCollector.PrintSummary True
127-
End If
128-
129-
End Sub
130-
13194
Public Property Get Configurator() As Object 'AccUnit.Configurator
13295
Set Configurator = AccUnitFactory.Configurator(CurrentVbProject)
13396
End Property
13497

135-
Public Property Get VbaTestSuite() As Object 'AccUnit.VbaTestSuite
136-
Set VbaTestSuite = AccUnitFactory.VbaTestSuite
137-
138-
With VbaTestSuite
139-
Set .HostApplication = Application
140-
Set .ActiveVBProject = CurrentVbProject
141-
Set .TestRunner = TestRunner
142-
End With
143-
144-
End Property
145-
14698
Public Property Get AccessTestSuite() As Object 'AccUnit.AccessTestSuite
14799
Set AccessTestSuite = AccUnitFactory.AccessTestSuite
148100

@@ -154,16 +106,30 @@ Public Property Get AccessTestSuite() As Object 'AccUnit.AccessTestSuite
154106

155107
End Property
156108

157-
Public Property Get DebugPrintTestSuite() As DebugPrintTestSuite
109+
Public Property Get TestSuite(Optional ByVal TestReportOutputTo As TestReportOutput = TestReportOutput.DebugPrint) As TestSuite
158110

159-
Set DebugPrintTestSuite = New DebugPrintTestSuite
111+
Set TestSuite = New TestSuite
160112

161-
With DebugPrintTestSuite
162-
.Init AccessTestSuite, NewDebugPrintTestResultCollector
113+
With TestSuite
114+
.Init AccessTestSuite, New TestResultCollector
163115
End With
164116

117+
AddTestResultReporter TestSuite, TestReportOutputTo
118+
165119
End Property
166120

121+
Private Sub AddTestResultReporter(ByVal TestSuite As TestSuite, ByVal TestReportOutputTo As TestReportOutput)
122+
123+
If (TestReportOutputTo And TestReportOutput.DebugPrint) = TestReportOutput.DebugPrint Then
124+
TestSuite.AddTestResultReporter New DebugPrintTestResultReporter
125+
End If
126+
127+
If (TestReportOutputTo And TestReportOutput.LogFile) = TestReportOutput.LogFile Then
128+
TestSuite.AddTestResultReporter New LogFileTestResultReporter
129+
End If
130+
131+
End Sub
132+
167133
Public Property Get CodeCoverageTracker() As Object 'AccUnit.CodeCoverageTracker
168134
Set CodeCoverageTracker = AccUnitFactory.CodeCoverageTracker(CurrentVbProject)
169135
End Property

access-add-in/source/modules/AccUnitLoaderFactoryCall.bas

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
'---------------------------------------------------------------------------------------
33
' Modul: AccUnitLoaderFactoryCall
44
'---------------------------------------------------------------------------------------
5-
'<codelib>
6-
' <file>%AppFolder%/source/GetAccUnitFactory.bas</file>
7-
' <license>_codelib/license.bas</license>
8-
' <use>%AppFolder%/source/AccUnitLoaderFactory.cls</use>
9-
'</codelib>
10-
'---
11-
Option Compare Database
5+
Option Compare Text
126
Option Explicit
137

148
Public Function GetAccUnitFactory() As AccUnitLoaderFactory

access-add-in/source/modules/AccUnitLoaderRibbonCallBacks.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Public Sub RemoveTestEnvironmentDelTestsRCB(Optional RibbonControl As Object)
4141
End Sub
4242

4343
Public Sub TestSuiteRunAllFromVBProjectRCB(Optional RibbonControl As Object)
44-
GetAccUnitFactory.DebugPrintTestSuite.AddFromVBProject.Run
44+
GetAccUnitFactory.TestSuite.AddFromVBProject.Run
4545
SetFocusToImmediateWindow
4646
End Sub
4747

access-add-in/source/modules/ApplicationHandler_AppFile.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Attribute VB_Description = "Erweiterung für ApplicationHandler-Klasse: Anwendun
3333
'</codelib>
3434
'---------------------------------------------------------------------------------------
3535
'
36-
Option Compare Database
36+
Option Compare Text
3737
Option Explicit
3838

3939
Private Const EXTENSION_KEY As String = "AppFile"

0 commit comments

Comments
 (0)