-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestTextRunner.prg
106 lines (71 loc) · 2.7 KB
/
TestTextRunner.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
95
96
97
98
99
100
101
102
103
104
105
106
//-- 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 TextTextRunner FROM TestRunner
DATA cResults
METHOD new() CONSTRUCTOR
METHOD showResults( oResult )
METHOD addResults( cResults, cResult )
ENDCLASS
//---------------------------------------------------------------------------//
METHOD new() CLASS TextTextRunner
::Super:new()
::cResults := ""
RETURN ( self )
//---------------------------------------------------------------------------//
METHOD addResults( ... ) CLASS TextTextRunner
local i
for i := 1 to pcount()
::cResults += hb_pvalue( i ) + CRLF
next
RETURN ( ::cResults )
//---------------------------------------------------------------------------//
METHOD showResults( oResult ) CLASS TextTextRunner
local i
local oError
local oFailure
local aErrors
local aFailures
local nErrors
local nFailures
aErrors := oResult:oData:getErrors()
aFailures := oResult:oData:getFailures()
nErrors := len( aErrors )
nFailures := len( aFailures )
::addResults( "Testcases: " + ltrim( str( oResult:oData:getTestCasesCount() ) ) )
::addResults( "Asserts: " + ltrim( str( oResult:oData:getAssertCount() ) ) )
::addResults( "Errors: " + ltrim( str( nErrors ) ) )
::addResults( "Failures: " + ltrim( str( nFailures ) ) )
if ( nErrors + nFailures == 0 )
::addResults( "Ok." )
end if
if ( nErrors > 0 )
::addResults( "Errors:" )
for i := 1 to nErrors
oError := aErrors[i]
::addResults( padl( i, 4 ), oError:description, oError:operation, if( !( empty( oError:args ) ), ::toStr( oError:args ), "" ) )
next
endif
if ( nFailures > 0 )
::addResults( "Failures:" )
for i := 1 to nFailures
oFailure := aFailures[i]
::addResults( padl( i, 4 ), oFailure:description, oFailure:operation, if( !( empty( oFailure:args ) ), ::toStr( oFailure:args ), "" ) )
next
endif
msgInfo( ::cResults, "Test information" )
RETURN ( nil )
//---------------------------------------------------------------------------//