author | Johnson Ma <johnson.ma@nokia.com> |
Mon, 29 Mar 2010 14:46:27 +0800 | |
changeset 1 | bbd31066657e |
parent 0 | 3e07fef1e154 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "symbianunittestresult.h" |
|
19 |
#include "symbianunittestfailure.h" |
|
20 |
#include "symbianunittestfileoutputwriter.h" |
|
21 |
#include "symbianunittestoutputastext.h" |
|
22 |
||
23 |
_LIT8( KTxtExecutedTests, "\r\n %d unit tests executed " ); |
|
24 |
_LIT8( KTxtPassedTests, " Passed tests: %d\r\n\r\n" ); |
|
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
25 |
_LIT8( KTxtPassedTest, " Test: " ); |
0 | 26 |
_LIT8( KTxtFailedTests, " Failed tests: %d\r\n\r\n" ); |
27 |
_LIT8( KTxtFailureTest, " Test: " ); |
|
28 |
_LIT8( KTxtFailureFile, " File: " ); |
|
29 |
_LIT8( KTxtFailureLine, " Line: %d\r\n" ); |
|
30 |
_LIT8( KTxtFailureReason, " Reason: " ); |
|
31 |
_LIT8( KLineEnd, "\r\n" ); |
|
32 |
||
33 |
// ----------------------------------------------------------------------------- |
|
34 |
// |
|
35 |
// ----------------------------------------------------------------------------- |
|
36 |
// |
|
37 |
CSymbianUnitTestOutputAsText* CSymbianUnitTestOutputAsText::NewL( |
|
38 |
const TDesC& aFileName ) |
|
39 |
{ |
|
40 |
CSymbianUnitTestOutputAsText* self = |
|
41 |
new( ELeave )CSymbianUnitTestOutputAsText; |
|
42 |
CleanupStack::PushL( self ); |
|
43 |
self->ConstructL( aFileName ); |
|
44 |
CleanupStack::Pop( self ); |
|
45 |
return self; |
|
46 |
} |
|
47 |
||
48 |
// ----------------------------------------------------------------------------- |
|
49 |
// |
|
50 |
// ----------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
CSymbianUnitTestOutputAsText::CSymbianUnitTestOutputAsText() |
|
53 |
{ |
|
54 |
} |
|
55 |
||
56 |
// ----------------------------------------------------------------------------- |
|
57 |
// |
|
58 |
// ----------------------------------------------------------------------------- |
|
59 |
// |
|
60 |
CSymbianUnitTestOutputAsText::~CSymbianUnitTestOutputAsText() |
|
61 |
{ |
|
62 |
} |
|
63 |
||
64 |
// ----------------------------------------------------------------------------- |
|
65 |
// From CSymbianUnitTestOutputFormatter |
|
66 |
// ----------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
const TDesC& CSymbianUnitTestOutputAsText::FileExtension() const |
|
69 |
{ |
|
70 |
return KTextOutput; |
|
71 |
} |
|
72 |
||
73 |
// ----------------------------------------------------------------------------- |
|
74 |
// From CSymbianUnitTestOutputFormatter |
|
75 |
// ----------------------------------------------------------------------------- |
|
76 |
// |
|
77 |
void CSymbianUnitTestOutputAsText::PrintHeaderL( |
|
78 |
CSymbianUnitTestResult& aResult ) |
|
79 |
{ |
|
80 |
iOutputWriter->WriteL( KTxtExecutedTests, aResult.TestCount() ); |
|
81 |
iOutputWriter->WriteDateAndTimeL(); |
|
82 |
iOutputWriter->WriteL( KLineEnd ); |
|
83 |
iOutputWriter->WriteL( KLineEnd ); |
|
84 |
} |
|
85 |
||
86 |
// ----------------------------------------------------------------------------- |
|
87 |
// From CSymbianUnitTestOutputFormatter |
|
88 |
// ----------------------------------------------------------------------------- |
|
89 |
// |
|
90 |
void CSymbianUnitTestOutputAsText::PrintPassedTestsL( |
|
91 |
CSymbianUnitTestResult& aResult ) |
|
92 |
{ |
|
93 |
iOutputWriter->WriteL( KTxtPassedTests, aResult.PassedTestCount() ); |
|
1
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
94 |
const CDesCArray& testCaseNames = aResult.TestCaseNames(); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
95 |
for ( TInt i=0; i < testCaseNames.Count(); i++ ) |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
96 |
{ |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
97 |
iOutputWriter->WriteL( KTxtPassedTest); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
98 |
iOutputWriter->WriteL( testCaseNames[i]); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
99 |
iOutputWriter->WriteL( KLineEnd ); |
bbd31066657e
publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents:
0
diff
changeset
|
100 |
} |
0 | 101 |
} |
102 |
||
103 |
// ----------------------------------------------------------------------------- |
|
104 |
// From CSymbianUnitTestOutputFormatter |
|
105 |
// ----------------------------------------------------------------------------- |
|
106 |
// |
|
107 |
void CSymbianUnitTestOutputAsText::PrintFailedTestsL( |
|
108 |
CSymbianUnitTestResult& aResult ) |
|
109 |
{ |
|
110 |
iOutputWriter->WriteL( KTxtFailedTests, aResult.Failures().Count() ); |
|
111 |
for ( TInt i=0; i < aResult.Failures().Count(); i++ ) |
|
112 |
{ |
|
113 |
PrintFailureDetailsL( *( aResult.Failures()[ i ] ) ); |
|
114 |
} |
|
115 |
} |
|
116 |
||
117 |
// ----------------------------------------------------------------------------- |
|
118 |
// From CSymbianUnitTestOutputFormatter |
|
119 |
// ----------------------------------------------------------------------------- |
|
120 |
// |
|
121 |
void CSymbianUnitTestOutputAsText::PrintFooterL() |
|
122 |
{ |
|
123 |
} |
|
124 |
||
125 |
// ----------------------------------------------------------------------------- |
|
126 |
// |
|
127 |
// ----------------------------------------------------------------------------- |
|
128 |
// |
|
129 |
void CSymbianUnitTestOutputAsText::PrintFailureDetailsL( |
|
130 |
CSymbianUnitTestFailure& aTestFailure ) |
|
131 |
{ |
|
132 |
iOutputWriter->WriteL( KTxtFailureTest ); |
|
133 |
iOutputWriter->WriteL( aTestFailure.TestName() ); |
|
134 |
iOutputWriter->WriteL( KLineEnd ); |
|
135 |
if ( aTestFailure.FileName().Length() > 0 ) |
|
136 |
{ |
|
137 |
iOutputWriter->WriteL( KTxtFailureFile ); |
|
138 |
iOutputWriter->WriteL( aTestFailure.FileName() ); |
|
139 |
iOutputWriter->WriteL( KLineEnd ); |
|
140 |
} |
|
141 |
if ( aTestFailure.LineNumber() >= 0 ) |
|
142 |
{ |
|
143 |
iOutputWriter->WriteL( KTxtFailureLine, aTestFailure.LineNumber() ); |
|
144 |
} |
|
145 |
iOutputWriter->WriteL( KTxtFailureReason ); |
|
146 |
iOutputWriter->WriteL( aTestFailure.FailureMessage() ); |
|
147 |
iOutputWriter->WriteL( KLineEnd ); |
|
148 |
iOutputWriter->WriteL( KLineEnd ); |
|
149 |
} |