summaryrefslogtreecommitdiff
path: root/wizards/source/sfunittests/SF_UnitTest.xba
blob: baeef90de3b38b50d052257f3e43f379bf7e5f1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
<?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_UnitTest" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
REM ===			The ScriptForge library and its associated libraries are part of the LibreOffice project.				===
REM ===					Full documentation is available on https://help.libreoffice.org/								===
REM =======================================================================================================================

Option Compatible
Option ClassModule

Option Explicit

&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
&apos;&apos;&apos;	SF_UnitTest
&apos;&apos;&apos;	===========
&apos;&apos;&apos;		Class providing a framework to execute and check sets of unit tests.
&apos;&apos;&apos;
&apos;&apos;&apos;		The UnitTest unit testing framework was originally inspired by unittest.py in Python
&apos;&apos;&apos;		and has a similar flavor as major unit testing frameworks in other languages.
&apos;&apos;&apos;
&apos;&apos;&apos;		It supports test automation, sharing of setup and shutdown code for tests,
&apos;&apos;&apos;		aggregation of tests into collections.
&apos;&apos;&apos;
&apos;&apos;&apos;		Both the
&apos;&apos;&apos;			- code describing the unit tests
&apos;&apos;&apos;			- code to be tested
&apos;&apos;&apos;		must be written exclusively in Basic (the code might call functions written in other languages).
&apos;&apos;&apos;		Even if either code may be contained in the same module, a much better practice is to
&apos;&apos;&apos;		store them in separate libraries.
&apos;&apos;&apos;		Typically:
&apos;&apos;&apos;			- in a same document when the code to be tested is contained in that document
&apos;&apos;&apos;			- either in a &quot;test&quot; document or in a &quot;My Macros&quot; library when the code
&apos;&apos;&apos;			  to be tested is a shared library (My Macros or LibreOffice Macros).
&apos;&apos;&apos;		The code to be tested may be released as an extension. It does not need to make
&apos;&apos;&apos;		use of ScriptForge services in any way.
&apos;&apos;&apos;
&apos;&apos;&apos;		The test reporting device is the Console. Read about the console in the ScriptForge.Exception service.
&apos;&apos;&apos;
&apos;&apos;&apos;		Definitions:
&apos;&apos;&apos;			- Test Case
&apos;&apos;&apos;				A test case is the individual unit of testing.
&apos;&apos;&apos;				It checks for a specific response to a particular set of inputs.
&apos;&apos;&apos;				A test case in the UnitTest service is represented by a Basic Sub.
&apos;&apos;&apos;				The name of the Sub starts conventionally with &quot;Test_&quot;.
&apos;&apos;&apos;				The test fails if one of the included AssertXXX methods returns False
&apos;&apos;&apos;			- Test Suite
&apos;&apos;&apos;				A test suite is a collection of test cases that should be executed together.
&apos;&apos;&apos;				A test suite is represented by a Basic module.
&apos;&apos;&apos;				A suite may include the tasks needed to prepare one or more tests, and any associated cleanup actions.
&apos;&apos;&apos;				This may involve, for example, creating temporary files or directories, opening a document, loading libraries.
&apos;&apos;&apos;				Conventionally those tasks are part pf the SetUp&apos;) and TearDown() methods.
&apos;&apos;&apos;			- Unit test
&apos;&apos;&apos;				A full unit test is a set of test suites (each suite in a separate Basic module),
&apos;&apos;&apos;				each of them being a set of test cases (each case is located in a separate Basic Sub).
&apos;&apos;&apos;
&apos;&apos;&apos;		Two modes:
&apos;&apos;&apos;			Beside the normal mode (&quot;full mode&quot;), using test suites and test cases, a second mode exists, called &quot;simple mode&quot;
&apos;&apos;&apos;			limited to the use exclusively of the Assert...() methods.
&apos;&apos;&apos;			Their boolean returned value may support the execution of limited unit tests.				
&apos;&apos;&apos;
&apos;&apos;&apos;		Service invocation examples:
&apos;&apos;&apos;			In full mode, the service creation is external to test cases
&apos;&apos;&apos;				Dim myUnitTest As Variant
&apos;&apos;&apos;				myUnitTest = CreateScriptService(&quot;UnitTest&quot;, ThisComponent, &quot;Tests&quot;)
&apos;&apos;&apos;								&apos;	Test code is in the library &quot;Tests&quot; located in the current document
&apos;&apos;&apos;			In simple mode, the service creation is internal to every test case
&apos;&apos;&apos;				Dim myUnitTest As Variant
&apos;&apos;&apos;				myUnitTest = CreateScriptService(&quot;UnitTest&quot;)
&apos;&apos;&apos;				With myUnitTest
&apos;&apos;&apos;					If Not .AssertTrue(...) Then ...			&apos;	Only calls to the Assert...() methods are allowed
&apos;&apos;&apos;					&apos;	...
&apos;&apos;&apos;					.Dispose()
&apos;&apos;&apos;				End With
&apos;&apos;&apos;
&apos;&apos;&apos;		Minimalist full mode example
&apos;&apos;&apos;			Code to be tested (stored in library &quot;Standard&quot; of document &quot;MyDoc.ods&quot;) :
&apos;&apos;&apos;				Function ArraySize(arr As Variant) As Long
&apos;&apos;&apos;					If IsArray(arr) Then ArraySize = UBound(arr) - LBound(arr) + 1 Else ArraySize = -1
&apos;&apos;&apos;				End Function
&apos;&apos;&apos;			Test code (stored in module &quot;AllTests&quot; of library &quot;Tests&quot; of document &quot;MyDoc.ods&quot;) :
&apos;&apos;&apos;				Sub Main()		&apos;	Sub to trigger manually, f.i. from the Tools + Run Macro tabbed bar
&apos;&apos;&apos;					GlobalScope.BasicLibraries.loadLibrary(&quot;ScriptForge&quot;)
&apos;&apos;&apos;					Dim test	:	test = CreateScriptService(&quot;UnitTest&quot;, ThisComponent, &quot;Tests&quot;)
&apos;&apos;&apos;					test.RunTest(&quot;AllTests&quot;)	&apos;	AllTests is a module name ; test cases are named &quot;Test_*&quot; (default)
&apos;&apos;&apos;					test.Dispose()
&apos;&apos;&apos;				End Sub
&apos;&apos;&apos;				REM ------------------------------------------------------------------------------
&apos;&apos;&apos;				Sub Setup(test)					&apos;	The unittest service is passed as argument
&apos;&apos;&apos;					&apos;	Optional Sub to initialize processing of the actual test suite
&apos;&apos;&apos;					Dim exc		:	exc = CreateScriptService(&quot;Exception&quot;)
&apos;&apos;&apos;					exc.Console(Modal := False)	&apos;	Watch test progress in the console
&apos;&apos;&apos;				End Sub
&apos;&apos;&apos;				REM ------------------------------------------------------------------------------
&apos;&apos;&apos;				Sub Test_ArraySize(test)
&apos;&apos;&apos;					On Local Error GoTo CatchErr
&apos;&apos;&apos;					test.AssertEqual(ArraySize(10), -1, &quot;When not array&quot;)
&apos;&apos;&apos;					test.AssertEqual(ArraySize(Array(1, 2, 3)), 3, &quot;When simple array&quot;)
&apos;&apos;&apos;					test.AssertEqual(ArraySize(DimArray(3)), 4, &quot;When array with empty items&quot;)
&apos;&apos;&apos;					Exit Sub
&apos;&apos;&apos;				CatchErr:
&apos;&apos;&apos;					test.ReportError(&quot;ArraySize() is corrupt&quot;)
&apos;&apos;&apos;				End Sub
&apos;&apos;&apos;				REM ------------------------------------------------------------------------------
&apos;&apos;&apos;				Sub TearDown(test)
&apos;&apos;&apos;					&apos;	Optional Sub to finalize processing of the actual test suite
&apos;&apos;&apos;				End Sub
&apos;&apos;&apos;
&apos;&apos;&apos;		Error handling
&apos;&apos;&apos;			To support the debugging of the tested code, the UnitTest service, in cases of
&apos;&apos;&apos;				- assertion failure
&apos;&apos;&apos;				- Basic run-time error in the tested code
&apos;&apos;&apos;				- Basic run-time error in the testing code (the unit tests)
&apos;&apos;&apos;			will comment the error location and description in a message box and in the console log,
&apos;&apos;&apos;			providing every test case (in either mode) implements an error handler containing at least:
&apos;&apos;&apos;				Sub Test_Case1(test As Variant)
&apos;&apos;&apos;					On Local Error GoTo Catch
&apos;&apos;&apos;					&apos; ... (AssertXXX(), Fail(), ...)
&apos;&apos;&apos;					Exit Sub
&apos;&apos;&apos;				Catch:
&apos;&apos;&apos;					test.ReportError()
&apos;&apos;&apos;				End Sub
&apos;&apos;&apos;
&apos;&apos;&apos;		Detailed user documentation:
&apos;&apos;&apos;			https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_unittest.html?DbPAR=BASIC
&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;

REM ================================================================== EXCEPTIONS

Private Const UNITTESTMETHODERROR		=	&quot;UNITTESTMETHODERROR&quot;

REM ============================================================= PRIVATE MEMBERS

Private [Me]				As Object
Private [_Parent]			As Object
Private ObjectType			As String		&apos; Must be &quot;UNITTEST&quot;
Private ServiceName			As String

&apos;	Testing code
Private LibrariesContainer	As String		&apos; Document or user Basic library containing the test library
Private Scope				As String		&apos; Scope when running a Basic script with Session.ExecuteBasicScript()
Private Libraries			As Variant		&apos; Set of libraries
Private LibraryName			As String		&apos; Name of the library containing the test code
Private LibraryIndex		As Integer		&apos; Index in Libraries
Private Modules				As Variant		&apos; Set of modules
Private ModuleNames			As Variant		&apos; Set of module names
Private MethodNames			As Variant		&apos; Set of methods in a given module

&apos;	Internals
Private _Verbose			As Boolean		&apos; When True, every assertion is reported,failing or not
Private _LongMessage		As Boolean		&apos; When False, only the message provided by the tester is considered
											&apos; When True (default), that message is appended to the standard message
Private _WhenAssertionFails	As Integer		&apos; Determines what to do when a test fails

&apos;	Test status
Private _Status				As Integer		&apos; 0 = standby
											&apos; 1 = test suite started
											&apos; 2 = setup started
											&apos; 3 = test case started
											&apos; 4 = teardown started
Private _ExecutionMode		As Integer		&apos; 1 = Test started with RunTest()
											&apos; 2 = Test started with CreateScriptService()	Only Assert() methods allowed
Private _Module				As String		&apos; Exact name of module currently running
Private _TestCase			As String		&apos; Exact name of test case currently running
Private _ReturnCode			As Integer		&apos; 0 = Normal end
											&apos; 1 = Assertion failed
											&apos; 2 = Skip request (in Setup() only)
											&apos;-1 = abnormal end
Private _FailedAssert		As String		&apos; Assert function that returned a failure

&apos;	Timers
Private TestTimer			As Object		&apos; Started by CreateScriptService()
Private SuiteTimer			As Object		&apos; Started by RunTest()
Private CaseTimer			As Object		&apos; Started by new case

&apos;	Services
Private Exception			As Object		&apos; SF_Exception
Private Session				As Object		&apos; SF_Session

REM ============================================================ MODULE CONSTANTS

&apos;	When assertion fails constants: error is reported + ...
Global Const FAILIGNORE			= 0			&apos; Ignore the failure
Global Const FAILSTOPSUITE		= 1			&apos; Module TearDown is executed, then next suite may be started (default in full mode)
Global Const FAILIMMEDIATESTOP	= 2			&apos; Stop immediately (default in simple mode)

&apos;	Unit tests status (internal use only =&gt; not Global)
Const STATUSSTANDBY				= 0			&apos; No test active
Const STATUSSUITESTARTED		= 1			&apos; RunTest() started
Const STATUSSETUP				= 2			&apos; A Setup() method is running
Const STATUSTESTCASE			= 3			&apos; A test case is running
Const STATUSTEARDOWN			= 4			&apos; A TearDown() method is running

&apos;	Return codes
Global Const RCNORMALEND		= 0			&apos; Normal end of test or test not started
Global Const RCASSERTIONFAILED	= 1			&apos; An assertion within a test case returned False
Global Const RCSKIPTEST			= 2			&apos; A SkipTest() was issued by a Setup() method
Global Const RCABORTTEST		= 3			&apos; Abnormal end of test

&apos;	Execution modes
Global Const FULLMODE			= 1			&apos; 1 = Test started with RunTest()
Global Const SIMPLEMODE			= 2			&apos; 2 = Test started with CreateScriptService()	Only Assert() methods allowed

Const INVALIDPROCEDURECALL		= &quot;5&quot;		&apos; Artificial error raised when an assertion fails

REM ===================================================== CONSTRUCTOR/DESTRUCTOR

REM -----------------------------------------------------------------------------
Private Sub Class_Initialize()
	Set [Me] = Nothing
	Set [_Parent] = Nothing
	ObjectType = &quot;UNITTEST&quot;
	ServiceName = &quot;SFUnitTests.UnitTest&quot;
	LibrariesContainer = &quot;&quot;
	Scope = &quot;&quot;
	Libraries = Array()
	LibraryName = &quot;&quot;
	LibraryIndex = -1
	_Verbose = False
	_LongMessage = True
	_WhenAssertionFails = -1
	_Status = STATUSSTANDBY
	_ExecutionMode = SIMPLEMODE
	_Module = &quot;&quot;
	_TestCase = &quot;&quot;
	_ReturnCode = RCNORMALEND
	_FailedAssert = &quot;&quot;
	Set TestTimer = Nothing
	Set SuiteTimer = Nothing
	Set CaseTimer = Nothing
	Set Exception = ScriptForge.SF_Exception	&apos;	Do not use CreateScriptService to allow New SF_UnitTest from other libraries
	Set Session = ScriptForge.SF_Session
End Sub		&apos;	SFUnitTests.SF_UnitTest Constructor

REM -----------------------------------------------------------------------------
Private Sub Class_Terminate()
	If Not IsNull(CaseTimer) Then CaseTimer = CaseTimer.Dispose()
	If Not IsNull(SuiteTimer) Then SuiteTimer = SuiteTimer.Dispose()
	If Not IsNull(TestTimer) Then TestTimer = TestTimer.Dispose()
	Call Class_Initialize()
End Sub		&apos;	SFUnitTests.SF_UnitTest Destructor

REM -----------------------------------------------------------------------------
Public Function Dispose() As Variant
	Call Class_Terminate()
	Set Dispose = Nothing
End Function	&apos;	SFUnitTests.SF_UnitTest Explicit destructor

REM ================================================================== PROPERTIES

REM -----------------------------------------------------------------------------
Property Get LongMessage() As Variant
&apos;&apos;&apos;	When False, only the message provided by the tester is considered
&apos;&apos;&apos;	When True (default), that message is appended to the standard message
	LongMessage = _PropertyGet(&quot;LongMessage&quot;)
End Property	&apos;	SFUnitTests.SF_UnitTest.LongMessage (get)

REM -----------------------------------------------------------------------------
Property Let LongMessage(Optional ByVal pvLongMessage As Variant)
&apos;&apos;&apos;	Set the updatable property LongMessage
	_PropertySet(&quot;LongMessage&quot;, pvLongMessage)
End Property	&apos;	SFUnitTests.SF_UnitTest.LongMessage (let)

REM -----------------------------------------------------------------------------
Property Get ReturnCode() As Integer
&apos;&apos;&apos;	RCNORMALEND			= 0				&apos; Normal end of test or test not started
&apos;&apos;&apos;	RCASSERTIONFAILED	= 1				&apos; An assertion within a test case returned False
&apos;&apos;&apos;	RCSKIPTEST			= 2				&apos; A SkipTest() was issued by a Setup() method
&apos;&apos;&apos;	RCABORTTEST			= 3				&apos; Abnormal end of test
	ReturnCode = _PropertyGet(&quot;ReturnCode&quot;)
End Property	&apos;	SFUnitTests.SF_UnitTest.ReturnCode (get)

REM -----------------------------------------------------------------------------
Property Get Verbose() As Variant
&apos;&apos;&apos;	The Verbose property indicates if all assertions (True AND False) are reported
	Verbose = _PropertyGet(&quot;Verbose&quot;)
End Property	&apos;	SFUnitTests.SF_UnitTest.Verbose (get)

REM -----------------------------------------------------------------------------
Property Let Verbose(Optional ByVal pvVerbose As Variant)
&apos;&apos;&apos;	Set the updatable property Verbose
	_PropertySet(&quot;Verbose&quot;, pvVerbose)
End Property	&apos;	SFUnitTests.SF_UnitTest.Verbose (let)

REM -----------------------------------------------------------------------------
Property Get WhenAssertionFails() As Variant
&apos;&apos;&apos;	What when an AssertXXX() method returns False
&apos;&apos;&apos;		FAILIGNORE			= 0				&apos; Ignore the failure
&apos;&apos;&apos;		FAILSTOPSUITE		= 1				&apos; Module TearDown is executed, then next suite may be started (default in FULL mode)
&apos;&apos;&apos;		FAILIMMEDIATESTOP	= 2				&apos; Stop immediately (default in SIMPLE mode)
&apos;&apos;&apos;	In simple mode, only FAILIGNORE and FAILIMMEDIATESTOP are allowed.
&apos;&apos;&apos;	In both modes, when WhenAssertionFails has not the value FAILIGNORE,
&apos;&apos;&apos;	each test case MUST have a run-time error handler calling the ReportError() method.
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		Sub Test_sometest(Optional test)
&apos;&apos;&apos;			On Local Error GoTo CatchError
&apos;&apos;&apos;			&apos;	...	one or more assert verbs
&apos;&apos;&apos;			Exit Sub
&apos;&apos;&apos;		CatchError:
&apos;&apos;&apos;			test.ReportError()
&apos;&apos;&apos;		End Sub
	WhenAssertionFails = _PropertyGet(&quot;WhenAssertionFails&quot;)
End Property	&apos;	SFUnitTests.SF_UnitTest.WhenAssertionFails (get)

REM -----------------------------------------------------------------------------
Property Let WhenAssertionFails(Optional ByVal pvWhenAssertionFails As Variant)
&apos;&apos;&apos;	Set the updatable property WhenAssertionFails
	_PropertySet(&quot;WhenAssertionFails&quot;, pvWhenAssertionFails)
End Property	&apos;	SFUnitTests.SF_UnitTest.WhenAssertionFails (let)

REM ===================================================================== METHODS

REM -----------------------------------------------------------------------------
Public Function AssertAlmostEqual(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Tolerance As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A and B are numerical values and are found close to each other.
&apos;&apos;&apos;	It is typically used to compare very large or very small numbers.
&apos;&apos;&apos;	Equality is confirmed when
&apos;&apos;&apos;		- A and B can be converted to doubles
&apos;&apos;&apos;		- The absolute difference between a and b, relative to the larger absolute value of a or b,
&apos;&apos;&apos;		  is lower or equal to the tolerance. The default tolerance is 1E-09,
&apos;&apos;&apos;			Examples:	1E+12 and 1E+12 + 100 are almost equal
&apos;&apos;&apos;						1E-20 and 2E-20 are not almost equal
&apos;&apos;&apos;						100 and 95 are almost equal when Tolerance = 0.05

Dim bAssert As Boolean			&apos;	Return value
Const cstTolerance = 1E-09
Const cstThisSub = &quot;UnitTest.AssertAlmostEqual&quot;
Const cstSubArgs = &quot;A, B, [Tolerance=1E-09], [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Tolerance) Then Tolerance = cstTolerance
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(Tolerance, &quot;Tolerance&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch

Try:
	bAssert = _Assert(&quot;AssertAlmostEqual&quot;, True, A, B, Message, Tolerance)

Finally:
	AssertAlmostEqual = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertAlmostEqual

REM -----------------------------------------------------------------------------
Public Function AssertEqual(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A and B are found equal.
&apos;&apos;&apos;	Equality is confirmed when
&apos;&apos;&apos;		If A and B are scalars:
&apos;&apos;&apos;			They should have the same VarType or both be numeric
&apos;&apos;&apos;			Booleans and numeric values are compared with the = operator
&apos;&apos;&apos;			Strings are compared with the StrComp() builtin function. The comparison is case-sensitive
&apos;&apos;&apos;			Dates and times are compared up to the second
&apos;&apos;&apos;			Null, Empty and Nothing are not equal, but AssertEqual(Nothing, Nothing) returns True
&apos;&apos;&apos;			UNO objects are compared with the EqualUnoObjects() method
&apos;&apos;&apos;			Basic objects are NEVER equal
&apos;&apos;&apos;		If A and B are arrays:
&apos;&apos;&apos;			They should have the same number of dimensions (maximum 2)
&apos;&apos;&apos;			The lower and upper bounds must be identical for each dimension
&apos;&apos;&apos;			Two empty arrays are equal
&apos;&apos;&apos;			Their items must be equal one by one

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertEqual&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertEqual&quot;, True, A, B, Message)

Finally:
	AssertEqual = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertEqual

REM -----------------------------------------------------------------------------
Public Function AssertFalse(Optional ByRef A As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is a Boolean and its value is False

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertFalse&quot;
Const cstSubArgs = &quot;A, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertFalse&quot;, True, A, Empty, Message)

Finally:
	AssertFalse = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertFalse

REM -----------------------------------------------------------------------------
Public Function AssertGreater(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is greater than B.
&apos;&apos;&apos;	To compare A and B:
&apos;&apos;&apos;		They should have the same VarType or both be numeric
&apos;&apos;&apos;		Eligible datatypes are String, Date or numeric.
&apos;&apos;&apos;		String comparisons are case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertGreater&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertGreater&quot;, True, A, B, Message)

Finally:
	AssertGreater = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertGreater

REM -----------------------------------------------------------------------------
Public Function AssertGreaterEqual(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is greater than or equal to B.
&apos;&apos;&apos;	To compare A and B:
&apos;&apos;&apos;		They should have the same VarType or both be numeric
&apos;&apos;&apos;		Eligible datatypes are String, Date or numeric.
&apos;&apos;&apos;		String comparisons are case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertGreaterEqual&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertGreaterEqual&quot;, True, A, B, Message)

Finally:
	AssertGreaterEqual = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertGreaterEqual

REM -----------------------------------------------------------------------------
Public Function AssertIn(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A, a string, is found within B
&apos;&apos;&apos;	B may be a 1D array, a ScriptForge dictionary or a string.
&apos;&apos;&apos;	When B is an array, A may be a date or a numeric value.
&apos;&apos;&apos;	String comparisons are case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertIn&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertIn&quot;, True, A, B, Message)

Finally:
	AssertIn = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertIn

REM -----------------------------------------------------------------------------
Public Function AssertIsInstance(Optional ByRef A As Variant _
								, Optional ByRef ObjectType As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is an object instance of the class ObjectType or a variable of type ObjectType.
&apos;&apos;&apos;	A may be:
&apos;&apos;&apos;		- a ScriptForge object
&apos;&apos;&apos;			ObjectType is a string like &quot;DICTIONARY&quot;, &quot;calc&quot;, &quot;Dialog&quot;, &quot;exception&quot;, etc.
&apos;&apos;&apos;		- a UNO object
&apos;&apos;&apos;			ObjectType is a string identical with values returned by the SF_Session.UnoObjectType()
&apos;&apos;&apos;		- any variable, providing it is neither an object nor an array
&apos;&apos;&apos;			ObjectType is a string identifying a value returned by the TypeName() builtin function
&apos;&apos;&apos;		- an array
&apos;&apos;&apos;			ObjectType is expected to be &quot;array&quot;

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertIsInstance&quot;
Const cstSubArgs = &quot;A, ObjectType, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(ObjectType) Then ObjectType = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(ObjectType, &quot;ObjectType&quot;, V_STRING) Then GoTo Catch


Try:
	bAssert = _Assert(&quot;AssertIsInstance&quot;, True, A, Empty, Message, ObjectType)

Finally:
	AssertIsInstance = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertIsInstance

REM -----------------------------------------------------------------------------
Public Function AssertIsNothing(Optional ByRef A As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is an object that has the Nothing value

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertIsNothing&quot;
Const cstSubArgs = &quot;A, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertIsNothing&quot;, True, A, Empty, Message)

Finally:
	AssertIsNothing = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertIsNothing

REM -----------------------------------------------------------------------------
Public Function AssertIsNull(Optional ByRef A As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A has the Null value

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertIsNull&quot;
Const cstSubArgs = &quot;A, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertIsNull&quot;, True, A, Empty, Message)

Finally:
	AssertIsNull = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertIsNull

REM -----------------------------------------------------------------------------
Public Function AssertLess(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is less than B.
&apos;&apos;&apos;	To compare A and B:
&apos;&apos;&apos;		They should have the same VarType or both be numeric
&apos;&apos;&apos;		Eligible datatypes are String, Date or numeric.
&apos;&apos;&apos;		String comparisons are case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertLess&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertLess&quot;, False, A, B, Message)

Finally:
	AssertLess = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertLess

REM -----------------------------------------------------------------------------
Public Function AssertLessEqual(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is less than or equal to B.
&apos;&apos;&apos;	To compare A and B:
&apos;&apos;&apos;		They should have the same VarType or both be numeric
&apos;&apos;&apos;		Eligible datatypes are String, Date or numeric.
&apos;&apos;&apos;		String comparisons are case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertLessEqual&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertLessEqual&quot;, False, A, B, Message)

Finally:
	AssertLessEqual = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertLessEqual

REM -----------------------------------------------------------------------------
Public Function AssertLike(Optional ByRef A As Variant _
								, Optional ByRef Pattern As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True if string A matches a given pattern containing wildcards
&apos;&apos;&apos;	Admitted wildcard are:	the &quot;?&quot; represents any single character
&apos;&apos;&apos;							the &quot;*&quot; represents zero, one, or multiple characters
&apos;&apos;&apos;	The comparison is case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertLike&quot;
Const cstSubArgs = &quot;A, Pattern, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Pattern) Then Pattern = &quot;&quot;
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(Pattern, &quot;Pattern&quot;, V_STRING) Then GoTo Catch

Try:
	bAssert = _Assert(&quot;AssertLike&quot;, True, A, Empty, Message, Pattern)

Finally:
	AssertLike = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertLike

REM -----------------------------------------------------------------------------
Public Function AssertNotAlmostEqual(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Tolerance As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A and B are numerical values and are not found close to each other.
&apos;&apos;&apos;	Read about almost equality in the comments linked to the AssertEqual() method.

Dim bAssert As Boolean			&apos;	Return value
Const cstTolerance = 1E-09
Const cstThisSub = &quot;UnitTest.AssertNotAlmostEqual&quot;
Const cstSubArgs = &quot;A, B, [Tolerance=1E-09], [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Tolerance) Then Tolerance = cstTolerance
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(Tolerance, &quot;Tolerance&quot;, ScriptForge.V_NUMERIC) Then GoTo Catch

Try:
	bAssert = _Assert(&quot;AssertNotAlmostEqual&quot;, False, A, B, Message, Tolerance)

Finally:
	AssertNotAlmostEqual = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotAlmostEqual

REM -----------------------------------------------------------------------------
Public Function AssertNotEqual(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A and B are found unequal.
&apos;&apos;&apos;	Read about equality in the comments linked to the AssertEqual() method.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertNotEqual&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertNotEqual&quot;, False, A, B, Message)

Finally:
	AssertNotEqual = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotEqual

REM -----------------------------------------------------------------------------
Public Function AssertNotIn(Optional ByRef A As Variant _
								, Optional ByRef B As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A, a string, is not found within B
&apos;&apos;&apos;	B may be a 1D array, a ScriptForge dictionary or a string.
&apos;&apos;&apos;	When B is an array, A may be a date or a numeric value.
&apos;&apos;&apos;	String comparisons are case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertNotIn&quot;
Const cstSubArgs = &quot;A, B, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(B) Then B = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertNotIn&quot;, False, A, B, Message)

Finally:
	AssertNotIn = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotIn

REM -----------------------------------------------------------------------------
Public Function AssertNotInstance(Optional ByRef A As Variant _
								, Optional ByRef ObjectType As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is an object instance of the class ObjectType or a variable of type ObjectType.
&apos;&apos;&apos;	More details to be read under the AssertInstance() function.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertNotInstance&quot;
Const cstSubArgs = &quot;A, ObjectType, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(ObjectType) Then ObjectType = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(ObjectType, &quot;ObjectType&quot;, V_STRING) Then GoTo Catch

Try:
	bAssert = _Assert(&quot;AssertNotInstance&quot;, False, A, Empty, Message, ObjectType)

Finally:
	AssertNotInstance = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotInstance

REM -----------------------------------------------------------------------------
Public Function AssertNotLike(Optional ByRef A As Variant _
								, Optional ByRef Pattern As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True if A is not a string or does not match a given pattern containing wildcards
&apos;&apos;&apos;	Admitted wildcard are:	the &quot;?&quot; represents any single character
&apos;&apos;&apos;							the &quot;*&quot; represents zero, one, or multiple characters
&apos;&apos;&apos;	The comparison is case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertNotLike&quot;
Const cstSubArgs = &quot;A, Pattern, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Pattern) Then Pattern = &quot;&quot;
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(Pattern, &quot;Pattern&quot;, V_STRING) Then GoTo Catch

Try:
	bAssert = _Assert(&quot;AssertNotLike&quot;, False, A, Empty, Message, Pattern)

Finally:
	AssertNotLike = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotLike

REM -----------------------------------------------------------------------------
Public Function AssertNotNothing(Optional ByRef A As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True except when A is an object that has the Nothing value

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertNotNothing&quot;
Const cstSubArgs = &quot;A, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertNotNothing&quot;, False, A, Empty, Message)

Finally:
	AssertNotNothing = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotNothing

REM -----------------------------------------------------------------------------
Public Function AssertNotNull(Optional ByRef A As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True except when A has the Null value

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertNotNull&quot;
Const cstSubArgs = &quot;A, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertNotNull&quot;, False, A, Empty, Message)

Finally:
	AssertNotNull = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotNull

REM -----------------------------------------------------------------------------
Public Function AssertNotRegex(Optional ByRef A As Variant _
								, Optional ByRef Regex As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is not a string or does not match the given regular expression.
&apos;&apos;&apos;	The comparison is case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertNotRegex&quot;
Const cstSubArgs = &quot;A, Regex, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Regex) Then Regex = &quot;&quot;
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(Regex, &quot;Regex&quot;, V_STRING) Then GoTo Catch

Try:
	bAssert = _Assert(&quot;AssertNotRegex&quot;, False, A, Empty, Message, Regex)

Finally:
	AssertNotRegex = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertNotRegex

REM -----------------------------------------------------------------------------
Public Function AssertRegex(Optional ByRef A As Variant _
								, Optional ByRef Regex As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when string A matches the given regular expression.
&apos;&apos;&apos;	The comparison is case-sensitive.

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertRegex&quot;
Const cstSubArgs = &quot;A, Regex, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Regex) Then Regex = &quot;&quot;
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(Regex, &quot;Regex&quot;, V_STRING) Then GoTo Catch

Try:
	bAssert = _Assert(&quot;AssertRegex&quot;, True, A, Empty, Message, Regex)

Finally:
	AssertRegex = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bAssert = False
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertRegex

REM -----------------------------------------------------------------------------
Public Function AssertTrue(Optional ByRef A As Variant _
								, Optional ByVal Message As Variant _
								) As Boolean
&apos;&apos;&apos;	Returns True when A is a Boolean and its value is True

Dim bAssert As Boolean			&apos;	Return value
Const cstThisSub = &quot;UnitTest.AssertTrue&quot;
Const cstSubArgs = &quot;A, [Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(A) Then A = Empty
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;AssertTrue&quot;, True, A, Empty, Message)

Finally:
	AssertTrue = bAssert
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest.AssertTrue

REM -----------------------------------------------------------------------------
Public Sub Fail(Optional ByVal Message As Variant)
&apos;&apos;&apos;	Forces a test failure

Dim bAssert As Boolean			&apos;	Fictive return value
Const cstThisSub = &quot;UnitTest.Fail&quot;
Const cstSubArgs = &quot;[Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	bAssert = _Assert(&quot;Fail&quot;, False, Empty, Empty, Message)

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Sub
End Sub	&apos;	SFUnitTests.SF_UnitTest.Fail

REM -----------------------------------------------------------------------------
Public Sub Log(Optional ByVal Message As Variant)
&apos;&apos;&apos;	Records the given message in the test report (console)

Dim bAssert As Boolean			&apos;	Fictive return value
Dim bVerbose As Boolean			:	bVerbose = _Verbose
Const cstThisSub = &quot;UnitTest.Log&quot;
Const cstSubArgs = &quot;[Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !

Try:
	&apos;	Force the display of the message in the console
	_Verbose = True
	bAssert = _Assert(&quot;Log&quot;, True, Empty, Empty, Message)
	_Verbose = bVerbose

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Sub
End Sub	&apos;	SFUnitTests.SF_UnitTest.Log

REM -----------------------------------------------------------------------------
Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
&apos;&apos;&apos;	Return the actual value of the given property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		PropertyName: the name of the property as a string
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		The actual value of the property
&apos;&apos;&apos;	Exceptions
&apos;&apos;&apos;		ARGUMENTERROR		The property does not exist
&apos;&apos;&apos;	Examples:
&apos;&apos;&apos;		myUnitTest.GetProperty(&quot;Duration&quot;)

Const cstThisSub = &quot;UnitTest.GetProperty&quot;
Const cstSubArgs = &quot;PropertyName&quot;

	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
	GetProperty = Null

Check:
	If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
		If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
	End If

Try:
	GetProperty = _PropertyGet(PropertyName)

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.Properties

REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
&apos;&apos;&apos;	Return the list or methods of the UnitTest class as an array

	Methods = Array( _
					&quot;AssertAlmostEqual&quot; _
					, &quot;AssertEqual&quot; _
					, &quot;AssertFalse&quot; _
					, &quot;AssertGreater&quot; _
					, &quot;AssertGreaterEqual&quot; _
					, &quot;AssertIn&quot; _
					, &quot;AssertIsInstance&quot; _
					, &quot;AssertIsNothing&quot; _
					, &quot;AssertLike&quot; _
					, &quot;AssertNotRegex&quot; _
					, &quot;AssertIsNull&quot; _
					, &quot;AssertLess&quot; _
					, &quot;AssertLessEqual&quot; _
					, &quot;AssertNotAlmostEqual&quot; _
					, &quot;AssertNotEqual&quot; _
					, &quot;AssertNotIn&quot; _
					, &quot;AssertNotInstance&quot; _
					, &quot;AssertNotLike&quot; _
					, &quot;AssertNotNothing&quot; _
					, &quot;AssertNotNull&quot; _
					, &quot;AssertRegex&quot; _
					, &quot;AssertTrue&quot; _
					, &quot;Fail&quot; _
					, &quot;Log&quot; _
					, &quot;RunTest&quot; _
					, &quot;SkipTest&quot; _
					)

End Function	&apos;	SFUnitTests.SF_UnitTest.Methods

REM -----------------------------------------------------------------------------
Public Function Properties() As Variant
&apos;&apos;&apos;	Return the list or properties of the UnitTest class as an array

	Properties = Array( _
					&quot;LongMessage&quot; _
					, &quot;ReturnCode&quot; _
					, &quot;Verbose&quot; _
					, &quot;WhenAssertionFails&quot; _
					)

End Function	&apos;	SFUnitTests.SF_UnitTest.Properties

REM -----------------------------------------------------------------------------
Public Sub ReportError(Optional ByVal Message As Variant)
&apos;&apos;&apos;	DIsplay a message box with the current property values of the &quot;Exception&quot; service.
&apos;&apos;&apos;	Depending on the WhenAssertionFails property, a Raise() or RaiseWarning()
&apos;&apos;&apos;	is issued. The Raise() method stops completely the Basic running process.
&apos;&apos;&apos;	The ReportError() method is presumed present in a user script in an error
&apos;&apos;&apos;	handling part of the actual testcase.
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		Message: a string to replace or to complete the standard message description
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		See the Test_ArraySize() sub in the module&apos;s heading example

Dim sLine As String				&apos;	Line number where the error occurred
Dim sError As String			&apos;	Exception description
Dim sErrorCode As String		&apos;	Exception number
Const cstThisSub = &quot;UnitTest.ReportError&quot;
Const cstSubArgs = &quot;[Message=&quot;&quot;&quot;&quot;]&quot;

Check:
	If IsMissing(Message) Or IsEmpty(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If VarType(Message) &lt;&gt; V_STRING Then Message = &quot;&quot;

Try:
	sLine = &quot;ln &quot; &amp; CStr(Exception.Source)
	If _ExecutionMode = FULLMODE Then sLine = _Module &amp; &quot;.&quot; &amp; _TestCase &amp; &quot; &quot; &amp; sLine
	If Len(Message) &gt; 0 Then
		sError = Message
	Else
		If Exception.Number = INVALIDPROCEDURECALL Then
			sError = &quot;Test case failure&quot;
			sErrorCode = &quot;ASSERTIONFAILED&quot;
		Else
			sError = Exception.Description
			sErrorCode = CStr(Exception.Number)
		End If
	End If

	Select Case _WhenAssertionFails
		Case FAILIGNORE
		Case FAILSTOPSUITE
			Exception.RaiseWarning(sErrorCode, sLine, sError)
		Case FAILIMMEDIATESTOP
			Exception.Raise(sErrorCode, sLine, sError)
	End Select

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Sub
End Sub			&apos;	SFUnitTests.SF_UnitTest.ReportError
REM -----------------------------------------------------------------------------
Public Function RunTest(Optional ByVal TestSuite As Variant _
							, Optional ByVal TestCasePattern As Variant _
							, Optional ByVal Message As Variant _
							) As Integer
&apos;&apos;&apos;	Execute a test suite pointed out by a module name.
&apos;&apos;&apos;	Each test case will be run independently from each other.
&apos;&apos;&apos;	The names of the test cases to be run may be selected with a string pattern.
&apos;&apos;&apos;	The test is &quot;orchestrated&quot; by this method:
&apos;&apos;&apos;		1. Execute the optional Setup() method present in the module
&apos;&apos;&apos;		2. Execute once each test case, in any order
&apos;&apos;&apos;		3, Execute the optional TearDown() method present in the module
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		TestSuite: the name of the module containing the set of test cases to run
&apos;&apos;&apos;		TestCasePattern: the pattern that the test cases must match. The comparison is not case-sensitive.
&apos;&apos;&apos;			Non-matching functions and subs are ignored.
&apos;&apos;&apos;			Admitted wildcard are:	the &quot;?&quot; represents any single character
&apos;&apos;&apos;									the &quot;*&quot; represents zero, one, or multiple characters
&apos;&apos;&apos;			The default pattern is &quot;Test_*&quot;
&apos;&apos;&apos;		Message: the message to be displayed in the console when the test starts.
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		One of the return codes of the execution (RCxxx constants)
&apos;&apos;&apos;	Examples:
&apos;&apos;&apos;		GlobalScope.BasicLibraries.loadLibrary(&quot;ScriptForge&quot;)
&apos;&apos;&apos;		Dim test	:	test = CreateScriptService(&quot;UnitTest&quot;, ThisComponent, &quot;Tests&quot;)
&apos;&apos;&apos;		test.RunTest(&quot;AllTests&quot;)	&apos;	AllTests is a module name ; test cases are named &quot;Test_*&quot; (default)

Dim iRun As Integer					&apos;	Return value
Dim sRunMessage As String			&apos;	Reporting
Dim iModule	As Integer				&apos;	Index of module currently running
Dim vMethods As Variant				&apos;	Set of methods
Dim sMethod As String				&apos;	A single method
Dim iMethod As Integer				&apos;	Index in MethodNames
Dim m As Integer

Const cstThisSub = &quot;UnitTest.RunTest&quot;
Const cstSubArgs = &quot;TestSuite, [TestCasePattern=&quot;&quot;Test_*&quot;&quot;], [Message=&quot;&quot;&quot;&quot;]&quot;

	iRun = RCNORMALEND
	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch

Check:
	If IsMissing(TestCasePattern) Or IsEmpty(TestCasePattern) Then TestCasePattern = &quot;Test_*&quot;
	If IsMissing(Message) Or IsEmpty(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(TestSuite, &quot;TestSuite&quot;, V_STRING, ModuleNames) Then GoTo Catch
	If Not ScriptForge.SF_Utils._Validate(TestCasePattern, &quot;TestCasePattern&quot;, V_STRING) Then GoTo Catch
	If Not ScriptForge.SF_Utils._Validate(Message, &quot;Message&quot;, V_STRING) Then GoTo Catch

	&apos;	A RunTest() is forbidden inside a test suite or when simple mode
	If _Status &lt;&gt; STATUSSTANDBY Or _ExecutionMode &lt;&gt; FULLMODE Then GoTo CatchMethod

	&apos;	Ignore any call when an abnormal end has been encountered
	If _ReturnCode = RCABORTTEST Then GoTo Catch

Try:
	iModule = ScriptForge.SF_Array.IndexOf(ModuleNames, TestSuite, CaseSensitive := False, SortOrder := &quot;ASC&quot;)
	_Module = ModuleNames(iModule)

	&apos;	Start timer
	If Not IsNull(SuiteTimer) Then SuiteTimer = SuiteTimer.Dispose()
	Set SuiteTimer = CreateScriptService(&quot;ScriptForge.Timer&quot;, True)

	&apos;	Report the start of a new test suite
	sRunMessage =  &quot;RUNTEST ENTER testsuite=&apos;&quot; &amp; LibraryName &amp; &quot;.&quot; &amp; _Module &amp; &quot;&apos;, pattern=&apos;&quot; &amp; TestCasePattern &amp; &quot;&apos;&quot;
	_ReportMessage(sRunMessage, Message)
	_Status = STATUSSUITESTARTED

	&apos;	Collect all the methods of the module
	If Modules(iModule).hasChildNodes() Then
		vMethods = Modules(iModule).getChildNodes()
		MethodNames = Array()
		For m = 0 To UBound(vMethods)
			sMethod = vMethods(m).getName()
			MethodNames = ScriptForge.SF_Array.Append(MethodNames, sMethod)
		Next m
	End If

	&apos;	Execute the Setup() method, if it exists
	iMethod = ScriptForge.SF_Array.IndexOf(MethodNames, &quot;Setup&quot;, CaseSensitive := False, SortOrder := &quot;ASC&quot;)
	If iMethod &gt;= 0 Then
		_TestCase = MethodNames(iMethod)	&apos;	_TestCase is used in ReportError()
		If Not _ExecuteScript(_TestCase) Then GoTo Catch
	End If

	&apos;	Execute the test cases that match the pattern
	For iMethod = 0 To UBound(MethodNames)
		If _ReturnCode = RCSKIPTEST Or _ReturnCode = RCASSERTIONFAILED Then Exit For
		sMethod = MethodNames(iMethod)
		If ScriptForge.SF_String.IsLike(sMethod, TestCasePattern, CaseSensitive := False) Then
			_TestCase = sMethod
			&apos;	Start timer
			If Not IsNull(CaseTimer) Then CaseTimer = CaseTimer.Dispose()
			Set CaseTimer = CreateScriptService(&quot;ScriptForge.Timer&quot;, True)
			If Not _ExecuteScript(sMethod) Then GoTo Catch
			CaseTimer.Terminate()
			_TestCase = &quot;&quot;
		End If
	Next iMethod

	If _ReturnCode &lt;&gt; RCSKIPTEST Then
		&apos;	Execute the TearDown() method, if it exists
		iMethod = ScriptForge.SF_Array.IndexOf(MethodNames, &quot;TearDown&quot;, CaseSensitive := False, SortOrder := &quot;ASC&quot;)
		If iMethod &gt;= 0 Then
			_TestCase = MethodNames(iMethod)	&apos;	_TestCase is used in ReportError()
			If Not _ExecuteScript(_TestCase) Then GoTo Catch
		End If
	End If

	&apos;	Report the end of the current test suite
	sRunMessage = &quot;RUNTEST EXIT testsuite=&apos;&quot; &amp; LibraryName &amp; &quot;.&quot; &amp; _Module &amp; &quot;&apos; &quot; &amp; _Duration(&quot;Suite&quot;, True)
	_ReportMessage(sRunMessage, Message)

	&apos;	Stop timer
	SuiteTimer.Terminate()

	&apos;	Housekeeping
	MethodNames = Array()
	_Module = &quot;&quot;
	_Status = STATUSSTANDBY

Finally:
	_ReturnCode = iRun
	RunTest = iRun
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	iRun = RCABORTTEST
	GoTo Finally
CatchMethod:
	ScriptForge.SF_Exception.RaiseFatal(UNITTESTMETHODERROR, &quot;RunTest&quot;)
	GoTo Catch
End Function	&apos;	SFUnitTests.SF_UnitTest.RunTest

REM -----------------------------------------------------------------------------
Public Function SetProperty(Optional ByVal PropertyName As Variant _
								, Optional ByRef Value As Variant _
								) As Boolean
&apos;&apos;&apos;	Set a new value to the given property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		PropertyName: the name of the property as a string
&apos;&apos;&apos;		Value: its new value
&apos;&apos;&apos;	Exceptions
&apos;&apos;&apos;		ARGUMENTERROR		The property does not exist

Const cstThisSub = &quot;UnitTest.SetProperty&quot;
Const cstSubArgs = &quot;PropertyName, Value&quot;

	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
	SetProperty = False

Check:
	If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
		If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
	End If

Try:
	SetProperty = _PropertySet(PropertyName, Value)

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest.SetProperty

REM -----------------------------------------------------------------------------
Public Function SkipTest(Optional ByVal Message As Variant) As Boolean
&apos;&apos;&apos;	Interrupt the running test suite. The TearDown() method is NOT executed.
&apos;&apos;&apos;	The SkipTest() method is normally meaningful only in a Setup() method when not all the
&apos;&apos;&apos;	conditions to run the test are met.
&apos;&apos;&apos;	It is up to the Setup() script to exit shortly after the SkipTest() call..
&apos;&apos;&apos;	The method may also be executed in a test case. Next test cases will not be executed.
&apos;&apos;&apos;	Remember however that the test cases are executed is an arbitrary order.
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		Message: the message to be displayed in the console
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		True when successful
&apos;&apos;&apos;	Examples:
&apos;&apos;&apos;		GlobalScope.BasicLibraries.loadLibrary(&quot;ScriptForge&quot;)
&apos;&apos;&apos;		Dim test	:	test = CreateScriptService(&quot;UnitTest&quot;, ThisComponent, &quot;Tests&quot;)
&apos;&apos;&apos;		test.SkipTest(&quot;AllTests&quot;)	&apos;	AllTests is a module name ; test cases are named &quot;Test_*&quot; (default)

Dim bSkip As Boolean				&apos;	Return value
Dim sSkipMessage As String			&apos;	Reporting

Const cstThisSub = &quot;UnitTest.SkipTest&quot;
Const cstSubArgs = &quot;[Message=&quot;&quot;&quot;&quot;]&quot;

	bSkip = False
	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch

Check:
	If IsMissing(Message) Or IsEmpty(Message) Then Message = &quot;&quot;
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)	&apos;	Unconditional !
	If Not ScriptForge.SF_Utils._Validate(Message, &quot;Message&quot;, V_STRING) Then GoTo Catch

	&apos;	A SkipTest() is forbidden when simple mode
	If _ExecutionMode &lt;&gt; FULLMODE Then GoTo CatchMethod

	&apos;	Ignore any call when an abnormal end has been encountered
	If _ReturnCode = RCABORTTEST Then GoTo Catch

Try:
	If _Status = STATUSSETUP Or _Status = STATUSTESTCASE Then
		_ReturnCode = RCSKIPTEST
		bSkip = True
		&apos;	Exit message
		sSkipMessage = &quot;    SKIPTEST testsuite=&apos;&quot; &amp; LibraryName &amp; &quot;.&quot; &amp; _Module &amp; &quot;&apos; &quot; &amp; _Duration(&quot;Suite&quot;, True)
		_ReportMessage(sSkipMessage, Message)
	End If

Finally:
	SkipTest = bSkip
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	_ReturnCode = RCABORTTEST
	GoTo Finally
CatchMethod:
	ScriptForge.SF_Exception.RaiseFatal(UNITTESTMETHODERROR, &quot;SkipTest&quot;)
	GoTo Catch
End Function	&apos;	SFUnitTests.SF_UnitTest.SkipTest

REM =========================================================== PRIVATE FUNCTIONS

REM -----------------------------------------------------------------------------
Private Function _Assert(ByVal psAssert As String _
							, ByVal pvReturn As Variant _
							, ByRef A As Variant _
							, ByRef B As Variant _
							, Optional ByVal pvMessage As Variant _
							, Optional ByVal pvArg As Variant _
							) As Boolean
&apos;&apos;&apos;	Evaluation of the assertion and management of the success or the failure
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psAssert: the assertion verb as a string
&apos;&apos;&apos;		pvReturn: may be True, False or Empty
&apos;&apos;&apos;			When True (resp. False), the assertion must be evaluated as True (resp. False)
&apos;&apos;&apos;				e.g.	AssertEqual() will call _Assert(&quot;AssertEqual&quot;, True, ...)
&apos;&apos;&apos;						AssertNotEqual() will call _Assert(&quot;AssertNotEqual&quot;, False, ...)
&apos;&apos;&apos;			Empty may be used for recursive calls of the function (for comparing arrays, ...)
&apos;&apos;&apos;		A: always present
&apos;&apos;&apos;		B: may be empty
&apos;&apos;&apos;		pvMessage: the message to display on the console
&apos;&apos;&apos;		pvArg: optional additional argument of the assert function
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		True when success

Dim bAssert As Boolean			&apos;	Return value
Dim bEval As Boolean			&apos;	To be compared with pvReturn
Dim iVarTypeA As Integer		&apos;	Alias of _VarTypeExt(A)
Dim iVarTypeB As Integer		&apos;	Alias of _VarTypeExt(B)
Dim oVarTypeObjA As Object		&apos;	SF_Utils.ObjectDescriptor
Dim oVarTypeObjB As Object		&apos;	SF_Utils.ObjectDescriptor
Dim oUtils As Object			:	Set oUtils = ScriptForge.SF_Utils
Dim iDims As Integer			&apos;	Number of dimensions of array
Dim oAliasB As Object			&apos;	Alias of B to bypass the &quot;Object variable not set&quot; issue
Dim dblA As Double				&apos;	Alias of A
Dim dblB As Double				&apos;	Alias of B
Dim dblTolerance As Double		&apos;	Alias of pvArg
Dim oString As Object			:	Set oString = ScriptForge.SF_String
Dim sArgName As String			&apos;	Argument description
Dim i As Long, j As Long

Check:
	bAssert = False
	If IsMissing(pvMessage) Then pvMessage = &quot;&quot;
	If Not oUtils._Validate(pvMessage, &quot;Message&quot;, V_STRING) Then GoTo Finally
	If IsMissing(pvArg) Then pvArg = &quot;&quot;

Try:
	iVarTypeA = oUtils._VarTypeExt(A)
	iVarTypeB = oUtils._VarTypeExt(B)
	sArgName = &quot;&quot;

	Select Case UCase(psAssert)
		Case UCase(&quot;AssertAlmostEqual&quot;), UCase(&quot;AssertNotAlmostEqual&quot;)
			bEval = ( iVarTypeA = iVarTypeB And iVarTypeA = ScriptForge.V_NUMERIC )
			If bEval Then
				dblA = CDbl(A)
				dblB = CDbl(B)
				dblTolerance = Abs(CDbl(pvArg))
				bEval = ( Abs(dblA - dblB) &lt;= (dblTolerance * Iif(Abs(dblA) &gt; Abs(DblB), Abs(dblA), Abs(dblB))) )
			End If
		Case UCase(&quot;AssertEqual&quot;), UCase(&quot;AssertNotEqual&quot;)
			If Not IsArray(A) Then
				bEval = ( iVarTypeA = iVarTypeB )
				If bEval Then
					Select Case iVarTypeA
						Case V_EMPTY, V_NULL
						Case V_STRING
							bEval = ( StrComp(A, B, 1) = 0 )
						Case ScriptForge.V_NUMERIC, ScriptForge.V_BOOLEAN
							bEval = ( A = B )
						Case V_DATE
							bEval = ( Abs(DateDiff(&quot;s&quot;, A, B)) = 0 )
						Case ScriptForge.V_OBJECT
							Set oVarTypeObjA = oUtils._VarTypeObj(A)
							Set oVarTypeObjB = oUtils._VarTypeObj(B)
							bEval = ( oVarTypeObjA.iVarType = oVarTypeObjB.iVarType )
							If bEval Then
								Select Case oVarTypeObjA.iVarType
									Case ScriptForge.V_NOTHING
									Case ScriptForge.V_UNOOBJECT
										bEval = EqualUnoObjects(A, B)
									Case ScriptForge.V_SFOBJECT, ScriptForge.V_BASICOBJECT
										bEval = False
								End Select
							End If
					End Select
				End If
			Else	&apos;	Compare arrays
				bEval = IsArray(B)
				If bEval Then
					iDims = ScriptForge.SF_Array.CountDims(A)
					bEval = ( iDims = ScriptForge.SF_Array.CountDims(B) And iDims &lt;= 2 )
					If bEval Then
						Select Case iDims
							Case -1, 0		&apos;	Scalars (not possible) or empty arrays
							Case 1			&apos;	1D array
								bEval = ( LBound(A) = LBound(B) And UBound(A) = UBound(B) )
								If bEval Then
									For i = LBound(A) To UBound(A)
										bEval = _Assert(psAssert, Empty, A(i), B(i))
										If Not bEval Then Exit For
									Next i
								End If
							Case 2			&apos;	2D array
								bEval = ( LBound(A, 1) = LBound(B, 1) And UBound(A, 1) = UBound(B, 1) _
										And LBound(A, 2) = LBound(B, 2) And UBound(A, 2) = UBound(B, 2) )
								If bEval Then
									For i = LBound(A, 1) To UBound(A, 1)
										For j = LBound(A, 2) To UBound(A, 2)
											bEval = _Assert(psAssert, Empty, A(i, j), B(i, j))
											If Not bEval Then Exit For
										Next j
										If Not bEval Then Exit For
									Next i
								End If
						End Select
					End If
				End If
			End If
		Case UCase(&quot;AssertFalse&quot;)
			If iVarTypeA = ScriptForge.V_BOOLEAN Then bEval = Not A Else bEval = False
		Case UCase(&quot;AssertGreater&quot;), UCase(&quot;AssertLessEqual&quot;)
			bEval = ( iVarTypeA = iVarTypeB _
						And (iVarTypeA = ScriptForge.V_NUMERIC Or iVarTypeA = V_STRING Or iVarTypeA = V_DATE) )
			If bEval Then bEval = ( A &gt; B )
		Case UCase(&quot;AssertGreaterEqual&quot;), UCase(&quot;AssertLess&quot;)
			bEval = ( iVarTypeA = iVarTypeB _
						And (iVarTypeA = ScriptForge.V_NUMERIC Or iVarTypeA = V_STRING Or iVarTypeA = V_DATE) )
			If bEval Then bEval = ( A &gt;= B )
		Case UCase(&quot;AssertIn&quot;), UCase(&quot;AssertNotIn&quot;)
			Set oVarTypeObjB = oUtils._VarTypeObj(B)
			Select Case True
				Case iVarTypeA = V_STRING And iVarTypeB = V_STRING
					bEval = ( Len(A) &gt; 0 And Len(B) &gt; 0 )
					If bEval Then bEval = ( InStr(1, B, A, 0) &gt; 0 )
				Case (iVarTypeA = V_DATE Or iVarTypeA = V_STRING Or iVarTypeA = ScriptForge.V_NUMERIC) _
						And iVarTypeB &gt;= ScriptForge.V_ARRAY
					bEval = ( ScriptForge.SF_Array.CountDims(B) = 1 )
					If bEval Then bEval = ScriptForge.SF_Array.Contains(B, A, CaseSensitive := True)
				Case oVarTypeObjB.iVarType = ScriptForge.V_SFOBJECT And oVarTypeObjB.sObjectType = &quot;DICTIONARY&quot;
					bEval = ( Len(A) &gt; 0 )
					If bEval Then
						Set oAliasB = B
						bEval = ScriptForge.SF_Array.Contains(oAliasB.Keys(), A, CaseSensitive := True)
					End If
				Case Else
					bEval = False
			End Select
		Case UCase(&quot;AssertIsInstance&quot;), UCase(&quot;AssertNotInstance&quot;)
			Set oVarTypeObjA = oUtils._VarTypeObj(A)
			sArgName = &quot;ObjectType&quot;
			With oVarTypeObjA
				Select Case .iVarType
					Case ScriptForge.V_UNOOBJECT
						bEval = ( pvArg = .sObjectType )
					Case ScriptForge.V_SFOBJECT
						bEval = ( UCase(pvArg) = UCase(.sObjectType) Or UCase(pvArg) = &quot;SF_&quot; &amp; UCase(.sObjectType) _
									Or UCase(pvArg) = UCase(.sServiceName) )
					Case ScriptForge.V_NOTHING, ScriptForge.V_BASICOBJECT
						bEval = False
					Case &gt;= ScriptForge.V_ARRAY
						bEval = ( UCase(pvArg) = &quot;ARRAY&quot; )
					Case Else
						bEval = ( UCase(TypeName(A)) = UCase(pvArg) )
				End Select
			End With
		Case UCase(&quot;AssertIsNothing&quot;), UCase(&quot;AssertNotNothing&quot;)
			bEval = ( iVarTypeA = ScriptForge.V_OBJECT )
			If bEval Then bEval = ( A Is Nothing )
		Case UCase(&quot;AssertIsNull&quot;), UCase(&quot;AssertNotNull&quot;)
			bEval = ( iVarTypeA = V_NULL )
		Case UCase(&quot;AssertLike&quot;), UCase(&quot;AssertNotLike&quot;)
			sArgName = &quot;Pattern&quot;
			bEval = ( iVarTypeA = V_STRING And Len(pvArg) &gt; 0 )
			If bEval Then bEval = oString.IsLike(A, pvArg, CaseSensitive := True)
		Case UCase(&quot;AssertRegex&quot;), UCase(&quot;AssertNotRegex&quot;)
			sArgName = &quot;Regex&quot;
			bEval = ( iVarTypeA = V_STRING And Len(pvArg) &gt; 0 )
			If bEval Then bEval = oString.IsRegex(A, pvArg, CaseSensitive := True)
		Case UCase(&quot;AssertTrue&quot;)
			If iVarTypeA = ScriptForge.V_BOOLEAN Then bEval = A Else bEval = False
		Case UCase(&quot;FAIL&quot;), UCase(&quot;Log&quot;)
			bEval = True
		Case Else
	End Select

	&apos;	Check the result of the assertion vs. what it should be
	If IsEmpty(pvReturn) Then
		bAssert = bEval		&apos;	Recursive call =&gt; Reporting and failure management are done by calling _Assert() procedure
	Else	&apos;	pvReturn is Boolean =&gt; Call from user script
		bAssert = Iif(pvReturn, bEval, Not bEval)
		&apos;	Report the assertion evaluation
		If _Verbose Or Not bAssert Then
			_ReportMessage(&quot;    &quot; &amp; psAssert _
							&amp; Iif(IsEmpty(A), &quot;&quot;, &quot; = &quot; &amp; bAssert &amp; &quot;, A = &quot; &amp; oUtils._Repr(A)) _
							&amp; Iif(IsEmpty(B), &quot;&quot;, &quot;, B = &quot; &amp; oUtils._Repr(B)) _
							&amp; Iif(Len(sArgName) = 0, &quot;&quot;, &quot;, &quot; &amp; sArgName &amp; &quot; = &quot; &amp; pvArg) _
							, pvMessage)
		End If
		&apos;	Manage assertion failure
		If Not bAssert Then
			_FailedAssert = psAssert
			Select Case _WhenAssertionFails
				Case FAILIGNORE			&apos;	Do nothing
				Case Else
					_ReturnCode = RCASSERTIONFAILED
					&apos;	Cause artificially a run-time error
					Dim STRINGBADUSE As String

					&apos;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
					&apos;+	To avoid a run-time error on next executable statement,						+
					&apos;+	insert an error handler in the code of your test case:						+
					&apos;+	Like in next code:															+
					&apos;+		On Local Error GoTo Catch												+
					&apos;+		...																		+
					&apos;+		Catch:																	+
					&apos;+			myTest.ReportError()												+
					&apos;+			Exit Sub															+
					&apos;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

					STRINGBADUSE = Right(&quot;&quot;, -1)	&apos;	Raises &quot;#5 - Invalid procedure call&quot; error

			End Select
		End If
	End If

Finally:
	_Assert = bAssert
	Exit Function

End Function	&apos;	SFUnitTests.SF_UnitTest._Assert

REM -----------------------------------------------------------------------------
Private Function _Duration(ByVal psTimer As String _
							, Optional ByVal pvBrackets As Variant _
							) As String
&apos;&apos;&apos;	Return the Duration property of the given timer
&apos;&apos;&apos;	or the empty string if the timer is undefined or not started
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psTimer: &quot;Test&quot;, &quot;Suite&quot; or &quot;TestCase&quot;
&apos;&apos;&apos;		pbBrackets: surround with brackets when True. Default = False

Dim sDuration As String			&apos;	Return value
Dim oTimer As Object			&apos;	Alias of psTimer

Check:
	If IsMissing(pvBrackets) Or IsEmpty(pvBrackets) Then pvBrackets = False

Try:
	Select Case psTimer
		Case &quot;Test&quot;					:	Set oTimer = TestTimer
		Case &quot;Suite&quot;				:	Set oTimer = SuiteTimer
		Case &quot;TestCase&quot;, &quot;Case&quot;		:	Set oTimer = CaseTimer
	End Select
	If Not IsNull(oTimer) Then
		sDuration = CStr(oTimer.Duration) &amp; &quot; &quot;
		If pvBrackets Then sDuration = &quot;(&quot; &amp; Trim(sDuration) &amp; &quot; sec)&quot;
	Else
		sDuration = &quot;&quot;
	End If

Finally:
	_Duration = sDuration
End Function	&apos;	SFUnitTests.SF_UnitTest._Duration

REM -----------------------------------------------------------------------------
Private Function _ExecuteScript(psMethod As String) As Boolean
&apos;&apos;&apos;	Run the given method and report start and stop
&apos;&apos;&apos;	The targeted method is presumed not to return anything (Sub)
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psMethod: the scope, the library and the module are predefined in the instance internals
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		True when successful

Dim bExecute As Boolean			&apos;	Return value
Dim sRun As String				&apos;	SETUP, TEARDOWN or TESTCASE

	On Local Error GoTo Catch
	bExecute = True

Try:
	&apos;	Set status before the effective execution
	sRun = UCase(psMethod)
	Select Case UCase(psMethod)
		Case &quot;SETUP&quot;		:	_Status = STATUSSETUP
		Case &quot;TEARDOWN&quot;		:	_Status = STATUSTEARDOWN
		Case Else			:	_Status = STATUSTESTCASE
								sRun = &quot;TESTCASE&quot;
	End Select

	&apos;	Report and execute
	_ReportMessage(&quot;  &quot; &amp; sRun &amp; &quot; &quot; &amp; LibraryName &amp; &quot;.&quot; &amp; _Module &amp; &quot;.&quot; &amp; psMethod &amp; &quot;() ENTER&quot;)
	Session.ExecuteBasicScript(Scope, LibraryName &amp; &quot;.&quot; &amp; _Module &amp; &quot;.&quot; &amp; psMethod, [Me])
	_ReportMessage(&quot;  &quot; &amp; sRun &amp; &quot; &quot; &amp; LibraryName &amp; &quot;.&quot; &amp; _Module &amp; &quot;.&quot; &amp; psMethod &amp; &quot;() EXIT&quot; _
			&amp; Iif(_STATUS = STATUSTESTCASE, &quot; &quot; &amp; _Duration(&quot;Case&quot;, True), &quot;&quot;))
	&apos;	Reset status
	_Status = STATUSSUITESTARTED

Finally:
	_ExecuteScript = bExecute
	Exit Function
Catch:
	bExecute = False
	_ReturnCode = RCABORTTEST
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest._ExecuteScript

REM -----------------------------------------------------------------------------
Private Function _PropertyGet(Optional ByVal psProperty As String)
&apos;&apos;&apos;	Return the named property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psProperty: the name of the property

Dim cstThisSub As String
Dim cstSubArgs As String

	cstThisSub = &quot;UnitTest.get&quot; &amp; psProperty
	cstSubArgs = &quot;&quot;
	SF_Utils._EnterFunction(cstThisSub, cstSubArgs)

	Select Case UCase(psProperty)
		Case UCase(&quot;LongMessage&quot;)
			_PropertyGet = _LongMessage
		Case UCase(&quot;ReturnCode&quot;)
			_PropertyGet = _ReturnCode
		Case UCase(&quot;Verbose&quot;)
			_PropertyGet = _Verbose
		Case UCase(&quot;WhenAssertionFails&quot;)
			_PropertyGet = _WhenAssertionFails
		Case Else
			_PropertyGet = Null
	End Select

Finally:
	SF_Utils._ExitFunction(cstThisSub)
	Exit Function
End Function	&apos;	SFUnitTests.SF_UnitTest._PropertyGet

REM -----------------------------------------------------------------------------
Private Function _PropertySet(Optional ByVal psProperty As String _
								, Optional ByVal pvValue As Variant _
								) As Boolean
&apos;&apos;&apos;	Set the new value of the named property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psProperty: the name of the property
&apos;&apos;&apos;		pvValue: the new value of the given property
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		True if successful

Dim bSet As Boolean							&apos;	Return value
Dim vWhenFailure As Variant					&apos;	WhenAssertionFails allowed values
Dim cstThisSub As String
Const cstSubArgs = &quot;Value&quot;

	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
	bSet = False

	cstThisSub = &quot;SFUnitTests.UnitTest.set&quot; &amp; psProperty
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)

	bSet = True
	Select Case UCase(psProperty)
		Case UCase(&quot;LongMessage&quot;)
			If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;LongMessage&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
			_LongMessage = pvValue
		Case UCase(&quot;Verbose&quot;)
			If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Verbose&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
			_Verbose = pvValue
		Case UCase(&quot;WhenAssertionFails&quot;)
			If _ExecutionMode = SIMPLEMODE Then vWhenFailure = Array(0, 3) Else vWhenFailure = Array(0, 1, 2, 3)
			If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;WhenAssertionFails&quot;, ScriptForge.V_NUMERIC, vWhenFailure) Then GoTo Finally
			_WhenAssertionFails = pvValue
		Case Else
			bSet = False
	End Select

Finally:
	_PropertySet = bSet
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	GoTo Finally
End Function	&apos;	SFUnitTests.SF_UnitTest._PropertySet

REM -----------------------------------------------------------------------------
Private Function _ReportMessage(ByVal psSysMessage As String _
								, Optional ByVal pvMessage As Variant _
								) As Boolean
&apos;&apos;&apos;	Report in the console:
&apos;&apos;&apos;		- either the standard message
&apos;&apos;&apos;		- either the user message when not blank
&apos;&apos;&apos;		- or both
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psSysMessage: the standard message as built by the calling routine
&apos;&apos;&apos;		psMessage: the message provided by the user script
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		True when successful

Dim bReport As Boolean			&apos;	Return value
Dim sIndent As String			&apos;	Indentation spaces

	bReport = False
	On Local Error GoTo Catch
	If IsMissing(pvMessage) Or IsEmpty(pvMessage) Then pvMessage = &quot;&quot;

Try:
	Select Case True
		Case Len(pvMessage) = 0
			Exception.DebugPrint(psSysMessage)
		Case _LongMessage
			Exception.DebugPrint(psSysMessage, pvMessage)
		Case Else
			Select Case _Status
				Case STATUSSTANDBY, STATUSSUITESTARTED	:	sIndent = &quot;&quot;
				Case STATUSSUITESTARTED					:	sIndent = Space(2)
				Case Else								:	sIndent = Space(4)
			End Select
			Exception.DebugPrint(sIndent &amp; pvMessage)
	End Select

Finally:
	_ReportMessage = bReport
	Exit Function
Catch:
	bReport = False
	GoTo Finally							
End Function	&apos;	SFUnitTests.SF_UnitTest._ReportMessage

REM -----------------------------------------------------------------------------
Private Function _Repr() As String
&apos;&apos;&apos;	Convert the UnitTest instance to a readable string, typically for debugging purposes (DebugPrint ...)
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;	Return:
&apos;&apos;&apos;		&quot;[UnitTest]

Const cstUnitTest = &quot;[UnitTest]&quot;
Const cstMaxLength = 50	&apos;	Maximum length for items

	_Repr = cstUnitTest

End Function	&apos;	SFUnitTests.SF_UnitTest._Repr

REM ============================================== END OF SFUNITTESTS.SF_UNITTEST
</script:module>