-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestResult.prg
94 lines (58 loc) · 2.23 KB
/
TestResult.prg
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
//-- copyright
// hbunit is a unit-testing framework for the Harbour language.
//
// Copyright (C) 2019 Manuel Calero Solis <manuelcalerosolis _at_ gmail _dot_ com>
//
// Based on hbunit from Enderson maia <endersonmaia _at_ gmail _dot_ com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// See COPYRIGHT for more details.
//++
#include "hbunit.ch"
//---------------------------------------------------------------------------//
CLASS TestResult
DATA oData
METHOD new() CONSTRUCTOR
METHOD run()
HIDDEN:
METHOD invokeTestMethod()
METHOD getTestMethods()
ENDCLASS
//---------------------------------------------------------------------------//
METHOD new() CLASS TestResult
::oData := TestResultData():new()
RETURN ( self )
//---------------------------------------------------------------------------//
METHOD run( oTest ) CLASS TestResult
local cMethod
local aTestMethods := ::getTestMethods( oTest )
::oData:addTestCaseCount( len( aTestMethods ) )
::invokeTestMethod( oTest, "BEFORECLASS" )
for each cMethod in aTestMethods
::invokeTestMethod( oTest, "BEFORE" )
::invokeTestMethod( oTest, cMethod )
::invokeTestMethod( oTest, "AFTER" )
next
::invokeTestMethod( oTest, "AFTERCLASS" )
RETURN ( nil )
//---------------------------------------------------------------------------//
METHOD getTestMethods( oTest ) CLASS TestResult
local aTestMethods := {}
local aMethods := __objGetMethodList( oTest )
aeval( aMethods, {| cMethod | if( left( cMethod, 5 ) == "TEST_", aadd( aTestMethods, cMethod ), ) } )
RETURN ( aTestMethods )
//---------------------------------------------------------------------------//
METHOD invokeTestMethod( oTest, cMethod ) CLASS TestResult
local oError
BEGIN SEQUENCE
__objSendMsg( oTest, cMethod )
RECOVER USING oError
oError:Args := oTest:ClassName() + ":" + cMethod
::addError( oError )
END
RETURN ( nil )
//---------------------------------------------------------------------------//