This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
TestResult.class.prg
78 lines (59 loc) · 1.75 KB
/
TestResult.class.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
//-- copyright
// hbunit is a unit-testing framework for the Harbour language.
//
// Copyright (C) 2014 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 TTestResult
METHOD new() CONSTRUCTOR
METHOD ClassName()
DATA cClassName
METHOD run()
DATA oData
HIDDEN:
METHOD invokeTestMethod()
METHOD getTestMethods()
ENDCLASS
METHOD new() CLASS TTestResult
::oData := TTestResultData():new()
::cClassName := "TTestResult"
RETURN( SELF )
METHOD ClassName() CLASS TTestResult
RETURN ( ::cClassName )
METHOD run( oTest ) CLASS TTestResult
LOCAL aTestMethods := ::getTestMethods( oTest ),;
nTestMethods := LEN ( aTestMethods ),;
i
::oData:addTestCaseCount( nTestMethods )
FOR i := 1 TO nTestMethods
::invokeTestMethod( oTest, "SETUP")
::invokeTestMethod( oTest, aTestMethods[i] )
::invokeTestMethod( oTest, "TEARDOWN")
NEXT
RETURN ( NIL )
METHOD getTestMethods( oTest ) CLASS TTestResult
LOCAL aMethods := __objGetMethodList( oTest ),;
aTestMethods := {},;
i
FOR i := 1 TO LEN( aMethods )
IF ( LEFT( aMethods[i], 4 ) == "TEST" )
AAdd( aTestMethods, aMethods[i] )
ENDIF
NEXT
RETURN ( aTestMethods )
METHOD invokeTestMethod( oTest, cMethod ) CLASS TTestResult
LOCAL oError
TRY EXCEPTION
__ObjSendMsg( oTest, cMethod )
CATCH EXCEPTION oError
oError:Args := oTest:ClassName() + ":" + cMethod
::addError( oError )
END TRY
RETURN ( NIL )