/documentation/html/_o_j_test_result_8j_source.html

http://github.com/hammerdr/OJTest · HTML · 160 lines · 159 code · 0 blank · 1 comment · 0 complexity · c7540ec2c372766f7d2c1cee87c02fd7 MD5 · raw file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>Objective-J Test API: Frameworks/OJUnit/OJTestResult.j Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.6.1 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul>
  14. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="annotated.html"><span>Classes</span></a></li>
  16. <li class="current"><a href="files.html"><span>Files</span></a></li>
  17. </ul>
  18. </div>
  19. <div class="tabs">
  20. <ul>
  21. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  22. <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  23. </ul>
  24. </div>
  25. <h1>Frameworks/OJUnit/OJTestResult.j</h1><a href="_o_j_test_result_8j.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 @<span class="keyword">import</span> &lt;Foundation/Foundation.j&gt;
  26. <a name="l00002"></a>00002
  27. <a name="l00003"></a>00003 @<span class="keyword">import</span> <span class="stringliteral">&quot;OJTestFailure.j&quot;</span>
  28. <a name="l00004"></a>00004
  29. <a name="l00005"></a><a class="code" href="class_o_j_test_result.html">00005</a> <span class="keyword">@implementation </span><a class="code" href="class_o_j_test_result.html">OJTestResult</a> : CPObject
  30. <a name="l00006"></a>00006 {
  31. <a name="l00007"></a>00007 <a class="code" href="class_c_p_array.html">CPArray</a> _failures;
  32. <a name="l00008"></a>00008 <a class="code" href="class_c_p_array.html">CPArray</a> _errors;
  33. <a name="l00009"></a>00009 <a class="code" href="class_c_p_array.html">CPArray</a> _listeners;
  34. <a name="l00010"></a>00010 <span class="keywordtype">int</span> _runTests;
  35. <a name="l00011"></a>00011 BOOL _stop;
  36. <a name="l00012"></a>00012 }
  37. <a name="l00013"></a>00013
  38. <a name="l00014"></a><a class="code" href="class_o_j_test_result.html#a958008622c78ca95ac1daa312aa68468">00014</a> - (id)init
  39. <a name="l00015"></a>00015 {
  40. <a name="l00016"></a>00016 <span class="keywordflow">if</span> (<span class="keyword">self</span> = [super init])
  41. <a name="l00017"></a>00017 {
  42. <a name="l00018"></a>00018 _failures = [];
  43. <a name="l00019"></a>00019 _errors = [];
  44. <a name="l00020"></a>00020 _listeners = [];
  45. <a name="l00021"></a>00021 _runTests = 0;
  46. <a name="l00022"></a>00022 _stop = NO;
  47. <a name="l00023"></a>00023 }
  48. <a name="l00024"></a>00024 <span class="keywordflow">return</span> <span class="keyword">self</span>;
  49. <a name="l00025"></a>00025 }
  50. <a name="l00026"></a>00026
  51. <a name="l00027"></a><a class="code" href="class_o_j_test_result.html#a81ee04efc244158e867430ce7c57d568">00027</a> - (void)addError:(CPException)error forTest:(OJTest)aTest
  52. <a name="l00028"></a>00028 {
  53. <a name="l00029"></a>00029 [_failures addObject:[[<a class="code" href="class_o_j_test_failure.html">OJTestFailure</a> alloc] initWithTest:aTest exception:error]];
  54. <a name="l00030"></a>00030 <span class="keywordflow">for</span> (var i = 0; i &lt; _listeners.length; i++)
  55. <a name="l00031"></a>00031 [_listeners[i] addError:error forTest:aTest];
  56. <a name="l00032"></a>00032 }
  57. <a name="l00033"></a>00033
  58. <a name="l00034"></a><a class="code" href="class_o_j_test_result.html#a2064f2b24f5bdf5352ad5af3c4128acb">00034</a> - (void)addFailure:(CPException)failure forTest:(OJTest)aTest
  59. <a name="l00035"></a>00035 {
  60. <a name="l00036"></a>00036 [_errors addObject:[[<a class="code" href="class_o_j_test_failure.html">OJTestFailure</a> alloc] initWithTest:aTest exception:failure]];
  61. <a name="l00037"></a>00037 <span class="keywordflow">for</span> (var i = 0; i &lt; _listeners.length; i++)
  62. <a name="l00038"></a>00038 [_listeners[i] addFailure:failure forTest:aTest];
  63. <a name="l00039"></a>00039 }
  64. <a name="l00040"></a>00040
  65. <a name="l00041"></a><a class="code" href="class_o_j_test_result.html#ad528fd618ba825e009057a9cf08ab0b9">00041</a> - (void)startTest:(OJTest)aTest
  66. <a name="l00042"></a>00042 {
  67. <a name="l00043"></a>00043 _runTests += [aTest countTestCases];
  68. <a name="l00044"></a>00044 <span class="keywordflow">for</span> (var i = 0; i &lt; _listeners.length; i++)
  69. <a name="l00045"></a>00045 [_listeners[i] startTest:aTest];
  70. <a name="l00046"></a>00046 }
  71. <a name="l00047"></a>00047
  72. <a name="l00048"></a><a class="code" href="class_o_j_test_result.html#a906bf681ca5917140341ad3966b6fe84">00048</a> - (void)endTest:(OJTest)aTest
  73. <a name="l00049"></a>00049 {
  74. <a name="l00050"></a>00050
  75. <a name="l00051"></a>00051 <span class="keywordflow">for</span> (var i = 0; i &lt; _listeners.length; i++)
  76. <a name="l00052"></a>00052 [_listeners[i] endTest:aTest];
  77. <a name="l00053"></a>00053 }
  78. <a name="l00054"></a>00054
  79. <a name="l00055"></a><a class="code" href="class_o_j_test_result.html#ac6751606953c05705d51a92172b8785a">00055</a> - (void)run:(<a class="code" href="class_o_j_test_case.html" title="A single test case.">OJTestCase</a>)aTest
  80. <a name="l00056"></a>00056 {
  81. <a name="l00057"></a>00057 [<span class="keyword">self</span> <a class="code" href="class_o_j_test_result.html#ad528fd618ba825e009057a9cf08ab0b9">startTest</a>:aTest];
  82. <a name="l00058"></a>00058
  83. <a name="l00059"></a>00059 <span class="keywordflow">try</span>
  84. <a name="l00060"></a>00060 {
  85. <a name="l00061"></a>00061 [aTest <a class="code" href="class_o_j_test_case.html#a7b8ba2493662e7a39f9bcbf4f388c3a6">runBare</a>];
  86. <a name="l00062"></a>00062 }
  87. <a name="l00063"></a>00063 <span class="keywordflow">catch</span> (e)
  88. <a name="l00064"></a>00064 {
  89. <a name="l00065"></a>00065 <span class="comment">// if not objj object, toll-free bridge to CPException</span>
  90. <a name="l00066"></a>00066 <span class="keywordflow">if</span> (!e.isa) {
  91. <a name="l00067"></a>00067 CPLog.warn(<span class="stringliteral">&quot;toll-free bridging e=&quot;</span>+e+<span class="stringliteral">&quot; to CPException&quot;</span>)
  92. <a name="l00068"></a>00068 e.isa = CPException;
  93. <a name="l00069"></a>00069 }
  94. <a name="l00070"></a>00070
  95. <a name="l00071"></a>00071 <span class="keywordflow">if</span> ([e name] == <a class="code" href="_o_j_test_case_8j.html#aa10f982f898aa31345dc071930167429">AssertionFailedError</a>)
  96. <a name="l00072"></a>00072 [<span class="keyword">self</span> <a class="code" href="class_o_j_test_result.html#a2064f2b24f5bdf5352ad5af3c4128acb">addFailure</a>:e <a class="code" href="class_o_j_test_result.html#a2064f2b24f5bdf5352ad5af3c4128acb">forTest</a>:aTest];
  97. <a name="l00073"></a>00073 <span class="keywordflow">else</span>
  98. <a name="l00074"></a>00074 [<span class="keyword">self</span> <a class="code" href="class_o_j_test_result.html#a81ee04efc244158e867430ce7c57d568">addError</a>:e <a class="code" href="class_o_j_test_result.html#a81ee04efc244158e867430ce7c57d568">forTest</a>:aTest];
  99. <a name="l00075"></a>00075 }
  100. <a name="l00076"></a>00076
  101. <a name="l00077"></a>00077 [<span class="keyword">self</span> <a class="code" href="class_o_j_test_result.html#a906bf681ca5917140341ad3966b6fe84">endTest</a>:aTest];
  102. <a name="l00078"></a>00078 }
  103. <a name="l00079"></a>00079
  104. <a name="l00080"></a><a class="code" href="class_o_j_test_result.html#afefb20de31199493e7d6a776525b68ba">00080</a> - (void)addListener:(OJTestListener)listener
  105. <a name="l00081"></a>00081 {
  106. <a name="l00082"></a>00082 [_listeners addObject:listener];
  107. <a name="l00083"></a>00083 }
  108. <a name="l00084"></a>00084
  109. <a name="l00085"></a><a class="code" href="class_o_j_test_result.html#ae8805ca853bf14f83bc253322d4b9b58">00085</a> - (void)removeListener:(OJTestListener)listener
  110. <a name="l00086"></a>00086 {
  111. <a name="l00087"></a>00087 [_listeners removeObject:listener];
  112. <a name="l00088"></a>00088 }
  113. <a name="l00089"></a>00089
  114. <a name="l00090"></a><a class="code" href="class_o_j_test_result.html#a618aefa522324d770cd30446650d2b39">00090</a> - (int)runCount
  115. <a name="l00091"></a>00091 {
  116. <a name="l00092"></a>00092 <span class="keywordflow">return</span> _runTests;
  117. <a name="l00093"></a>00093 }
  118. <a name="l00094"></a>00094
  119. <a name="l00095"></a><a class="code" href="class_o_j_test_result.html#ae969b06b725ae1dad3a61487f0afd6ea">00095</a> - (BOOL)shouldStop
  120. <a name="l00096"></a>00096 {
  121. <a name="l00097"></a>00097 <span class="keywordflow">return</span> _stop;
  122. <a name="l00098"></a>00098 }
  123. <a name="l00099"></a>00099
  124. <a name="l00100"></a><a class="code" href="class_o_j_test_result.html#a596cb460a67d01b0246dbfa2cb55465d">00100</a> - (void)stop
  125. <a name="l00101"></a>00101 {
  126. <a name="l00102"></a>00102 _stop = YES;
  127. <a name="l00103"></a>00103 }
  128. <a name="l00104"></a>00104
  129. <a name="l00105"></a><a class="code" href="class_o_j_test_result.html#ab7725dc356d3013abbd64c09b1b4ae1a">00105</a> - (int)failureCount
  130. <a name="l00106"></a>00106 {
  131. <a name="l00107"></a>00107 <span class="keywordflow">return</span> [_failures count];
  132. <a name="l00108"></a>00108 }
  133. <a name="l00109"></a>00109
  134. <a name="l00110"></a><a class="code" href="class_o_j_test_result.html#afd4c5ac643f6c2c745dbb8fb26f1d4ea">00110</a> - (<a class="code" href="class_c_p_array.html">CPArray</a>)failures
  135. <a name="l00111"></a>00111 {
  136. <a name="l00112"></a>00112 <span class="keywordflow">return</span> _failures;
  137. <a name="l00113"></a>00113 }
  138. <a name="l00114"></a>00114
  139. <a name="l00115"></a><a class="code" href="class_o_j_test_result.html#a825348fdab6a8f2bb27a2309af371781">00115</a> - (int)errorCount
  140. <a name="l00116"></a>00116 {
  141. <a name="l00117"></a>00117 <span class="keywordflow">return</span> [_errors count];
  142. <a name="l00118"></a>00118 }
  143. <a name="l00119"></a>00119
  144. <a name="l00120"></a><a class="code" href="class_o_j_test_result.html#abc8c820f190b9ec947f7f35b62c1d343">00120</a> - (<a class="code" href="class_c_p_array.html">CPArray</a>)errors
  145. <a name="l00121"></a>00121 {
  146. <a name="l00122"></a>00122 <span class="keywordflow">return</span> _errors;
  147. <a name="l00123"></a>00123 }
  148. <a name="l00124"></a>00124
  149. <a name="l00125"></a><a class="code" href="class_o_j_test_result.html#a23e0b484fab4c6989bea71f8f79564c0">00125</a> - (BOOL)wasSuccessful
  150. <a name="l00126"></a>00126 {
  151. <a name="l00127"></a>00127 <span class="keywordflow">return</span> [<span class="keyword">self</span> <a class="code" href="class_o_j_test_result.html#ab7725dc356d3013abbd64c09b1b4ae1a">failureCount</a>] == 0 &amp;&amp; [<span class="keyword">self</span> <a class="code" href="class_o_j_test_result.html#a825348fdab6a8f2bb27a2309af371781">errorCount</a>] == 0;
  152. <a name="l00128"></a>00128 }
  153. <a name="l00129"></a>00129
  154. <a name="l00130"></a>00130 <span class="keyword">@end</span>
  155. </pre></div></div>
  156. <hr size="1"/><address style="text-align: right;"><small>Generated on Sat Feb 20 02:20:16 2010 for Objective-J Test API by&nbsp;
  157. <a href="http://www.doxygen.org/index.html">
  158. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
  159. </body>
  160. </html>