ScriptForge - New 'UnitTest' service for Basic
The "UnitTest" service is implemented as a new Basic library called 'SFUnitTests'. ScriptForge unit tests (SF_UnitTest class module) ====================== Class providing a framework to execute and check sets of unit tests. The UnitTest unit testing framework was originally inspired by unittest.py in Python and has a similar flavor as major unit testing frameworks in other languages. It supports - test automation - sharing of setupand shutdown code - aggregation of tests into collections. Both the - code describing the unit tests - code to be tested must be written exclusively in Basic (the code might call functions written in other languages). The code to be tested may be released as an extension. It does not need to make use of ScriptForge services. The test reporting device is the Console. Definitions: - Test Case: each test case is a Basic Sub. - Test Suite: a collection of test cases stored in 1 Basic module. - Unit test: a set of test suites stored in 1 library. Two modes: - the normal mode ("full mode"), using test suites and test cases The UnitTest service is passed as argument to each test case. - the "simple mode" limited to the use of the Assert...() methods. Service invocation examples: - In full mode, the service creation is external to test cases Dim myUnitTest As Variant myUnitTest = CreateScriptService("UnitTest", ThisComponent, "Tests") ' Test code is in the library "Tests" ' located in the current document - In simple mode, the service creation is internal to every test case Dim myUnitTest As Variant myUnitTest = CreateScriptService("UnitTest") With myUnitTest If Not .AssertTrue(...) Then ... ' ... .Dispose() End With Error handling To support the debugging of the tested code, the UnitTest service, in cases of - assertion failure - Basic run-time error in the tested code - Basic run-time error in the testing code (the unit tests) will comment the error location and description in a message box and in the console log, providing every test case (in either mode) implements an error handler containing at least a call to the ReportError() method. Change-Id: I9d9b889b148f172cd868af455493c8c696d1e953 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135365 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
This commit is contained in:
parent
cfb5148b56
commit
14c7bc1c90
18 changed files with 2171 additions and 4 deletions
|
@ -1002,6 +1002,7 @@ $(eval $(call gb_Helper_register_packages_for_install,ooo,\
|
|||
wizards_basicsrvsfdatabases \
|
||||
wizards_basicsrvsfdialogs \
|
||||
wizards_basicsrvsfdocuments \
|
||||
wizards_basicsrvsfunittests \
|
||||
wizards_basicsrvsfwidgets \
|
||||
wizards_basicsrvstandard \
|
||||
wizards_basicsrvtemplate \
|
||||
|
|
|
@ -75,6 +75,7 @@ $(eval $(call gb_CppunitTest_use_packages,desktop_lib, \
|
|||
wizards_basicsrvsfdatabases \
|
||||
wizards_basicsrvsfdialogs \
|
||||
wizards_basicsrvsfdocuments \
|
||||
wizards_basicsrvsfunittests \
|
||||
wizards_basicsrvsfwidgets \
|
||||
wizards_basicsrvtemplate \
|
||||
wizards_basicsrvtools \
|
||||
|
|
|
@ -285,6 +285,11 @@ Directory gid_Dir_Basic_SFDocuments
|
|||
DosName = "SFDocuments";
|
||||
End
|
||||
|
||||
Directory gid_Dir_Basic_SFUnitTests
|
||||
ParentID = gid_Dir_Basic;
|
||||
DosName = "SFUnitTests";
|
||||
End
|
||||
|
||||
Directory gid_Dir_Basic_SFWidgets
|
||||
ParentID = gid_Dir_Basic;
|
||||
DosName = "SFWidgets";
|
||||
|
|
|
@ -33,6 +33,7 @@ $(eval $(call gb_Module_add_targets,wizards,\
|
|||
Package_sfdatabases \
|
||||
Package_sfdialogs \
|
||||
Package_sfdocuments \
|
||||
Package_sfunittests \
|
||||
Package_sfwidgets \
|
||||
Package_standard \
|
||||
Package_template \
|
||||
|
|
30
wizards/Package_sfunittests.mk
Normal file
30
wizards/Package_sfunittests.mk
Normal file
|
@ -0,0 +1,30 @@
|
|||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# This file incorporates work covered by the following license notice:
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed
|
||||
# with this work for additional information regarding copyright
|
||||
# ownership. The ASF licenses this file to you under the Apache
|
||||
# License, Version 2.0 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
#
|
||||
|
||||
$(eval $(call gb_Package_Package,wizards_basicsrvsfunittests,$(SRCDIR)/wizards/source/sfunittests))
|
||||
|
||||
$(eval $(call gb_Package_add_files,wizards_basicsrvsfunittests,$(LIBO_SHARE_FOLDER)/basic/SFUnitTests,\
|
||||
SF_Register.xba \
|
||||
SF_UnitTest.xba \
|
||||
__License.xba \
|
||||
dialog.xlb \
|
||||
script.xlb \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
|
@ -14,5 +14,6 @@
|
|||
<library:library library:name="SFDatabases" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFDatabases/dialog.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFDialogs" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFDialogs/dialog.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFDocuments" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFDocuments/dialog.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFUnitTests" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFUnitTests/dialog.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFWidgets" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFWidgets/dialog.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
</library:libraries>
|
||||
|
|
|
@ -14,5 +14,6 @@
|
|||
<library:library library:name="SFDatabases" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFDatabases/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFDialogs" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFDialogs/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFDocuments" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFDocuments/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFUnitTests" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFUnitTests/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
<library:library library:name="SFWidgets" xlink:href="$(INST)/@LIBO_SHARE_FOLDER@/basic/SFWidgets/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
|
||||
</library:libraries>
|
||||
|
|
|
@ -133,6 +133,10 @@ Const SQLSYNTAXERROR = "SQLSYNTAXERROR"
|
|||
' Python
|
||||
Const PYTHONSHELLERROR = "PYTHONSHELLERROR"
|
||||
|
||||
' SF_UnitTest
|
||||
Const UNITTESTLIBRARYERROR = "UNITTESTLIBRARYERROR"
|
||||
Const UNITTESTMETHODERROR = "UNITTESTMETHODERROR"
|
||||
|
||||
REM ============================================================= PRIVATE MEMBERS
|
||||
|
||||
' User defined errors
|
||||
|
@ -1025,6 +1029,12 @@ Try:
|
|||
Case PYTHONSHELLERROR ' SF_Exception.PythonShell (Python only)
|
||||
sMessage = sLocation _
|
||||
& "\n" & "\n" & .GetText("PYTHONSHELL")
|
||||
Case UNITTESTLIBRARYERROR ' SFUnitTests._NewUnitTest(LibraryName)
|
||||
sMessage = sLocation _
|
||||
& "\n" & "\n" & .GetText("UNITTESTLIBRARY", pvArgs(0))
|
||||
Case UNITTESTMETHODERROR ' SFUnitTests.SF_UnitTest(Method)
|
||||
sMessage = sLocation _
|
||||
& "\n" & "\n" & .GetText("UNITTESTMETHOD", pvArgs(0))
|
||||
Case Else
|
||||
End Select
|
||||
End With
|
||||
|
|
|
@ -1012,6 +1012,21 @@ Try:
|
|||
, Comment := "SF_Exception.PythonShell error message" _
|
||||
& "APSO: to leave unchanged" _
|
||||
)
|
||||
' SFUnitTests._NewUnitTest
|
||||
.AddText( Context := "UNITTESTLIBRARY" _
|
||||
, MsgId := "The requested library could not be located.\n" _
|
||||
& "The UnitTest service has not been initialized.\n\n" _
|
||||
& "Library name : « %1 »" _
|
||||
, Comment := "SFUnitTest could not locate the library gven as argument\n" _
|
||||
& "%1: The name of the library" _
|
||||
)
|
||||
' SFUnitTests.SF_UnitTest
|
||||
.AddText( Context := "UNITTESTMETHOD" _
|
||||
, MsgId := "The method '%1' is unexpected in the current context.\n" _
|
||||
& "The UnitTest service cannot proceed further with the on-going test." _
|
||||
, Comment := "SFUnitTest finds a RunTest() call in a inappropriate location\n" _
|
||||
& "%1: The name of a method" _
|
||||
)
|
||||
End With
|
||||
End If
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ Try:
|
|||
sLibrary = "SFDocuments"
|
||||
Case "dialog", "dialogevent" : sLibrary = "SFDialogs"
|
||||
Case "database" : sLibrary = "SFDatabases"
|
||||
Case "unittest" : sLibrary = "SFUnitTests"
|
||||
Case "menu", "popupmenu" : sLibrary = "SFWidgets"
|
||||
Case Else
|
||||
End Select
|
||||
|
|
|
@ -51,8 +51,9 @@ Global Const V_SFOBJECT = 103 ' ScriptForge object: has Object
|
|||
Global Const V_BASICOBJECT = 104 ' User Basic object
|
||||
|
||||
Type _ObjectDescriptor ' Returned by the _VarTypeObj() method
|
||||
iVarType As Integer ' One of the V_NOTHING, V_xxxOBJECT constants
|
||||
sObjectType As String ' Either "" or "com.sun.star..." or a ScriptForge object type (ex. "SF_SESSION" or "DICTIONARY")
|
||||
iVarType As Integer ' One of the V_NOTHING, V_xxxOBJECT constants
|
||||
sObjectType As String ' Either "" or "com.sun.star..." or a ScriptForge object type (ex. "SF_SESSION" or "DICTIONARY")
|
||||
sServiceName As String ' Either "" or the service name of a ScriptForge object type (ex. "ScriptForge.Exception"-
|
||||
End Type
|
||||
|
||||
REM ================================================================== EXCEPTIONS
|
||||
|
@ -1065,6 +1066,7 @@ Try:
|
|||
With oObjDesc
|
||||
.iVarType = VarType(pvValue)
|
||||
.sObjectType = ""
|
||||
.sServiceName = ""
|
||||
bUno = False
|
||||
If .iVarType = V_OBJECT Then
|
||||
If IsNull(pvValue) Then
|
||||
|
@ -1089,6 +1091,7 @@ Try:
|
|||
bUno = False
|
||||
' Try if the Basic object has an ObjectType property
|
||||
.sObjectType = oValue.ObjectType
|
||||
.sServiceName = oValue.ServiceName
|
||||
End If
|
||||
' Derive the return value from the object type
|
||||
Select Case True
|
||||
|
|
|
@ -14,7 +14,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n"
|
||||
"POT-Creation-Date: 2022-03-09 14:52:15\n"
|
||||
"POT-Creation-Date: 2022-05-04 18:07:20\n"
|
||||
"PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
|
||||
|
@ -952,4 +952,24 @@ msgctxt "PYTHONSHELL"
|
|||
msgid ""
|
||||
"The APSO extension could not be located in your LibreOffice "
|
||||
"installation."
|
||||
msgstr ""
|
||||
|
||||
#. SFUnitTest could not locate the library gven as argument
|
||||
#. %1: The name of the library
|
||||
#, kde-format
|
||||
msgctxt "UNITTESTLIBRARY"
|
||||
msgid ""
|
||||
"The requested library could not be located.\n"
|
||||
"The UnitTest service has not been initialized.\n"
|
||||
"\n"
|
||||
"Library name : « %1 »"
|
||||
msgstr ""
|
||||
|
||||
#. SFUnitTest finds a RunTest() call in a inappropriate location
|
||||
#. %1: The name of a method
|
||||
#, kde-format
|
||||
msgctxt "UNITTESTMETHOD"
|
||||
msgid ""
|
||||
"The method '%1' is unexpected in the current context.\n"
|
||||
"The UnitTest service cannot proceed further with the on-going test."
|
||||
msgstr ""
|
|
@ -14,7 +14,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n"
|
||||
"POT-Creation-Date: 2022-03-09 14:52:15\n"
|
||||
"POT-Creation-Date: 2022-05-04 18:07:20\n"
|
||||
"PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
|
||||
|
@ -952,4 +952,24 @@ msgctxt "PYTHONSHELL"
|
|||
msgid ""
|
||||
"The APSO extension could not be located in your LibreOffice "
|
||||
"installation."
|
||||
msgstr ""
|
||||
|
||||
#. SFUnitTest could not locate the library gven as argument
|
||||
#. %1: The name of the library
|
||||
#, kde-format
|
||||
msgctxt "UNITTESTLIBRARY"
|
||||
msgid ""
|
||||
"The requested library could not be located.\n"
|
||||
"The UnitTest service has not been initialized.\n"
|
||||
"\n"
|
||||
"Library name : « %1 »"
|
||||
msgstr ""
|
||||
|
||||
#. SFUnitTest finds a RunTest() call in a inappropriate location
|
||||
#. %1: The name of a method
|
||||
#, kde-format
|
||||
msgctxt "UNITTESTMETHOD"
|
||||
msgid ""
|
||||
"The method '%1' is unexpected in the current context.\n"
|
||||
"The UnitTest service cannot proceed further with the on-going test."
|
||||
msgstr ""
|
202
wizards/source/sfunittests/SF_Register.xba
Normal file
202
wizards/source/sfunittests/SF_Register.xba
Normal file
|
@ -0,0 +1,202 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_Register" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
|
||||
REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
|
||||
REM === The SFUnitTests library is one of the associated libraries. ===
|
||||
REM === Full documentation is available on https://help.libreoffice.org/ ===
|
||||
REM =======================================================================================================================
|
||||
|
||||
Option Compatible
|
||||
Option Explicit
|
||||
|
||||
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
''' SF_Register
|
||||
''' ===========
|
||||
''' The ScriptForge framework includes
|
||||
''' the master ScriptForge library
|
||||
''' a number of "associated" libraries SF*
|
||||
''' any user/contributor extension wanting to fit into the framework
|
||||
'''
|
||||
''' The main methods in this module allow the current library to cling to ScriptForge
|
||||
''' - RegisterScriptServices
|
||||
''' Register the list of services implemented by the current library
|
||||
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
REM ================================================================== EXCEPTIONS
|
||||
|
||||
Private Const UNITTESTLIBRARYERROR = "UNITTESTLIBRARYERROR"
|
||||
|
||||
REM ============================================================== PUBLIC METHODS
|
||||
|
||||
REM -----------------------------------------------------------------------------
|
||||
Public Sub RegisterScriptServices() As Variant
|
||||
''' Register into ScriptForge the list of the services implemented by the current library
|
||||
''' Each library pertaining to the framework must implement its own version of this method
|
||||
'''
|
||||
''' It consists in successive calls to the RegisterService() and RegisterEventManager() methods
|
||||
''' with 2 arguments:
|
||||
''' ServiceName: the name of the service as a case-insensitive string
|
||||
''' ServiceReference: the reference as an object
|
||||
''' If the reference refers to a module, then return the module as an object:
|
||||
''' GlobalScope.Library.Module
|
||||
''' If the reference is a class instance, then return a string referring to the method
|
||||
''' containing the New statement creating the instance
|
||||
''' "libraryname.modulename.function"
|
||||
|
||||
With GlobalScope.ScriptForge.SF_Services
|
||||
.RegisterService("UnitTest", "SFUnitTests.SF_Register._NewUnitTest") ' Reference to the function initializing the service
|
||||
End With
|
||||
|
||||
End Sub ' SFUnitTests.SF_Register.RegisterScriptServices
|
||||
|
||||
REM =========================================================== PRIVATE FUNCTIONS
|
||||
|
||||
REM -----------------------------------------------------------------------------
|
||||
Public Function _NewUnitTest(Optional ByVal pvArgs As Variant) As Object
|
||||
''' Create a new instance of the SF_UnitTest class
|
||||
' Args:
|
||||
''' Location: if empty, the location of the library is presumed to be in GlobalScope.BasicLibraries
|
||||
''' Alternatives are:
|
||||
''' - the name of a document: see SF_UI.WindowName
|
||||
''' - an explicit SFDocuments.Document instance
|
||||
''' - the component containing the library, typically ThisComponent
|
||||
''' LibraryName: the name of the library containing the test code
|
||||
''' Returns:
|
||||
''' The instance or Nothing
|
||||
''' Exceptions:
|
||||
''' UNITTESTLIBRARYNOTFOUND The library could not be found
|
||||
|
||||
Dim oUnitTest As Object ' Return value
|
||||
Dim vLocation As Variant ' Alias of pvArgs(0)
|
||||
Dim vLibraryName As Variant ' alias of pvArgs(1)
|
||||
Dim vLocations As Variant ' "user", "share" or document
|
||||
Dim sLocation As String ' A single location
|
||||
Dim sTargetLocation As String ' "user" or the document name
|
||||
Dim vLanguages As Variant ' "Basic", "Python", ... programming languages
|
||||
Dim sLanguage As String ' A single programming language
|
||||
Dim vLibraries As Variant ' Library names
|
||||
Dim sLibrary As String ' A single library
|
||||
Dim vModules As Variant ' Module names
|
||||
Dim sModule As String ' A single module
|
||||
Dim vModuleNames As Variant ' Module names
|
||||
Dim oRoot As Object ' com.sun.star.script.browse.BrowseNodeFactory
|
||||
Dim iLibrary As Integer ' The index of the target location in vLibraries
|
||||
|
||||
Dim FSO As Object ' SF_FileSystem
|
||||
Dim i As Integer, j As Integer, k As Integer, l As Integer
|
||||
|
||||
Const cstService = "SFUnitTests.UnitTest"
|
||||
|
||||
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
|
||||
|
||||
Check:
|
||||
If IsMissing(pvArgs) Or IsEmpty(pvArgs) Then pvArgs = Array()
|
||||
If UBound(pvArgs) >= 0 Then vLocation = pvArgs(0) Else vLocation = ""
|
||||
If IsEmpty(vLocation) Then vLocation = ""
|
||||
If UBound(pvArgs) >= 1 Then vLibraryName = pvArgs(1) Else vLibraryName = ""
|
||||
If IsEmpty(vLibraryName) Then vLibraryName = ""
|
||||
If Not ScriptForge.SF_Utils._Validate(vLocation, "Location", Array(V_STRING, ScriptForge.V_OBJECT)) Then GoTo Finally
|
||||
If Not ScriptForge.SF_Utils._Validate(vLibraryName, "LibraryName", V_STRING) Then GoTo Finally
|
||||
|
||||
Set oUnitTest = Nothing
|
||||
Set FSO = CreateScriptService("ScriptForge.FileSystem")
|
||||
|
||||
' Determine the library container hosting the test code
|
||||
|
||||
' Browsing starts from root element
|
||||
Set oRoot = SF_Utils._GetUNOService("BrowseNodeFactory").createView(com.sun.star.script.browse.BrowseNodeFactoryViewTypes.MACROORGANIZER)
|
||||
|
||||
If Len(vLibraryName) > 0 Then
|
||||
|
||||
' Determine the target location, as a string. The location is either:
|
||||
' - the last component of a document's file name
|
||||
' - "user" = My Macros & Dialogs
|
||||
If VarType(vLocation) = ScriptForge.V_OBJECT Then
|
||||
sTargetLocation = FSO.GetName(vLocation.URL)
|
||||
ElseIf Len(vLocation) = 0 Then
|
||||
sTargetLocation = "user" ' Testing code is presumed NOT in "share"
|
||||
Else
|
||||
sTargetLocation = FSO.GetName(vLocation)
|
||||
End If
|
||||
|
||||
' Exploration is done via tree nodes
|
||||
iLibrary = -1
|
||||
If Not IsNull(oRoot) Then
|
||||
If oRoot.hasChildNodes() Then
|
||||
vLocations = oRoot.getChildNodes()
|
||||
For i = 0 To UBound(vLocations)
|
||||
sLocation = vLocations(i).getName()
|
||||
If sLocation = sTargetLocation Then
|
||||
If vLocations(i).hasChildNodes() Then
|
||||
vLanguages = vLocations(i).getChildNodes()
|
||||
For j = 0 To UBound(vLanguages)
|
||||
sLanguage = vLanguages(j).getName()
|
||||
' Consider Basic libraries only
|
||||
If sLanguage = "Basic" Then
|
||||
If vLanguages(j).hasChildNodes() Then
|
||||
vLibraries = vLanguages(j).getChildNodes()
|
||||
For k = 0 To UBound(vLibraries)
|
||||
sLibrary = vLibraries(k).getName()
|
||||
' Consider the targeted library only
|
||||
If sLibrary = vLibraryName Then
|
||||
iLibrary = k
|
||||
If vLibraries(k).hasChildNodes() Then
|
||||
vModules = vLibraries(k).getChildNodes()
|
||||
vModuleNames = Array()
|
||||
For l = 0 To UBound(vModules)
|
||||
sModule = vModules(l).getName()
|
||||
vModuleNames = ScriptForge.SF_Array.Append(vModuleNames, sModule)
|
||||
Next l
|
||||
End If
|
||||
Exit For
|
||||
End If
|
||||
Next k
|
||||
End If
|
||||
End If
|
||||
If iLibrary >= 0 Then Exit For
|
||||
Next j
|
||||
End If
|
||||
End If
|
||||
If iLibrary >= 0 Then Exit For
|
||||
Next i
|
||||
End If
|
||||
End If
|
||||
If iLibrary < 0 Then GoTo CatchLibrary
|
||||
|
||||
End If
|
||||
|
||||
Try:
|
||||
' Create the unittest Basic object and initialize its attributes
|
||||
Set oUnitTest = New SF_UnitTest
|
||||
With oUnitTest
|
||||
Set .[Me] = oUnitTest
|
||||
If Len(vLibraryName) > 0 Then
|
||||
.LibrariesContainer = sTargetLocation
|
||||
.Scope = Iif(sTargetLocation = "user", "application", "document")
|
||||
.Libraries = vLibraries
|
||||
.LibraryName = sLibrary
|
||||
.LibraryIndex = iLibrary
|
||||
.Modules = vModules
|
||||
.ModuleNames = vModuleNames
|
||||
._ExecutionMode = .FULLMODE
|
||||
._WhenAssertionFails = .FAILSTOPSUITE
|
||||
' Launch the test timer
|
||||
.TestTimer = CreateScriptService("ScriptForge.Timer", True)
|
||||
Else
|
||||
._ExecutionMode = .SIMPLEMODE
|
||||
._WhenAssertionFails = .FAILIMMEDIATESTOP
|
||||
End If
|
||||
End With
|
||||
|
||||
Finally:
|
||||
Set _NewUnitTest = oUnitTest
|
||||
Exit Function
|
||||
Catch:
|
||||
GoTo Finally
|
||||
CatchLibrary:
|
||||
ScriptForge.SF_Exception.RaiseFatal(UNITTESTLIBRARYERROR, vLibraryName)
|
||||
GoTo Finally
|
||||
End Function ' SFUnitTests.SF_Register._NewUnitTest
|
||||
|
||||
REM ============================================== END OF SFUNITTESTS.SF_REGISTER
|
||||
</script:module>
|
1820
wizards/source/sfunittests/SF_UnitTest.xba
Normal file
1820
wizards/source/sfunittests/SF_UnitTest.xba
Normal file
File diff suppressed because it is too large
Load diff
26
wizards/source/sfunittests/__License.xba
Normal file
26
wizards/source/sfunittests/__License.xba
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
|
||||
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="__License" script:language="StarBasic" script:moduleType="normal">
|
||||
''' Copyright 2019-2022 Jean-Pierre LEDURE, Rafael LIMA, Alain ROMEDENNE
|
||||
|
||||
REM =======================================================================================================================
|
||||
REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
|
||||
REM === The SFUnitTests library is one of the associated libraries. ===
|
||||
REM === Full documentation is available on https://help.libreoffice.org/ ===
|
||||
REM =======================================================================================================================
|
||||
|
||||
''' ScriptForge is distributed in the hope that it will be useful,
|
||||
''' but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
''' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
''' ScriptForge is free software; you can redistribute it and/or modify it under the terms of either (at your option):
|
||||
|
||||
''' 1) The Mozilla Public License, v. 2.0. If a copy of the MPL was not
|
||||
''' distributed with this file, you can obtain one at http://mozilla.org/MPL/2.0/ .
|
||||
|
||||
''' 2) The GNU Lesser General Public License as published by
|
||||
''' the Free Software Foundation, either version 3 of the License, or
|
||||
''' (at your option) any later version. If a copy of the LGPL was not
|
||||
''' distributed with this file, see http://www.gnu.org/licenses/ .
|
||||
|
||||
</script:module>
|
3
wizards/source/sfunittests/dialog.xlb
Normal file
3
wizards/source/sfunittests/dialog.xlb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
|
||||
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="SFUnitTests" library:readonly="false" library:passwordprotected="false"/>
|
7
wizards/source/sfunittests/script.xlb
Normal file
7
wizards/source/sfunittests/script.xlb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
|
||||
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="SFUnitTests" library:readonly="false" library:passwordprotected="false">
|
||||
<library:element library:name="__License"/>
|
||||
<library:element library:name="SF_UnitTest"/>
|
||||
<library:element library:name="SF_Register"/>
|
||||
</library:library>
|
Loading…
Reference in a new issue