diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2022-06-03 17:51:57 +0200 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2022-06-04 12:08:36 +0200 |
commit | 14c7bc1c90d671743c2f25b6958bb54f03140597 (patch) | |
tree | 442620aadc5225817daa4155258c12577f481180 /scp2/source/ooo | |
parent | cfb5148b56560a28fe4b790be12caa09fd05b492 (diff) |
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>
Diffstat (limited to 'scp2/source/ooo')
-rw-r--r-- | scp2/source/ooo/directory_ooo.scp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/scp2/source/ooo/directory_ooo.scp b/scp2/source/ooo/directory_ooo.scp index 66c895575a7f..71bc2f2f76eb 100644 --- a/scp2/source/ooo/directory_ooo.scp +++ b/scp2/source/ooo/directory_ooo.scp @@ -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"; |