/GHUnitIOS.framework/Versions/A/Headers/GHTesting.h

http://github.com/zwaldowski/BlocksKit · C++ Header · 151 lines · 27 code · 22 blank · 102 comment · 0 complexity · 745a22d3c44bd66bbb6aac133d8a9017 MD5 · raw file

  1. //
  2. // GHTesting.h
  3. // GHUnit
  4. //
  5. // Created by Gabriel Handford on 1/30/09.
  6. // Copyright 2008 Gabriel Handford
  7. //
  8. // Permission is hereby granted, free of charge, to any person
  9. // obtaining a copy of this software and associated documentation
  10. // files (the "Software"), to deal in the Software without
  11. // restriction, including without limitation the rights to use,
  12. // copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. // copies of the Software, and to permit persons to whom the
  14. // Software is furnished to do so, subject to the following
  15. // conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  22. // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  24. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  25. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  27. // OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. //! @cond DEV
  30. //
  31. // Portions of this file fall under the following license, marked with:
  32. // GTM_BEGIN : GTM_END
  33. //
  34. // Copyright 2008 Google Inc.
  35. //
  36. // Licensed under the Apache License, Version 2.0 (the "License"); you may not
  37. // use this file except in compliance with the License. You may obtain a copy
  38. // of the License at
  39. //
  40. // http://www.apache.org/licenses/LICENSE-2.0
  41. //
  42. // Unless required by applicable law or agreed to in writing, software
  43. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  44. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  45. // License for the specific language governing permissions and limitations under
  46. // the License.
  47. //
  48. #import <Foundation/Foundation.h>
  49. #import "GHUnit.h"
  50. #ifdef __cplusplus
  51. extern "C" NSString *GHUStackTraceFromException(NSException *e);
  52. #else
  53. extern NSString *GHUStackTraceFromException(NSException *e);
  54. #endif
  55. // GTM_BEGIN
  56. BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
  57. // GTM_END
  58. /*!
  59. Utility test for loading and running tests.
  60. @note Much of this is borrowed from GTM/UnitTesting.
  61. */
  62. @interface GHTesting : NSObject {
  63. NSMutableArray/* of NSString*/ *testCaseClassNames_;
  64. }
  65. /*!
  66. The shared testing instance.
  67. */
  68. + (GHTesting *)sharedInstance;
  69. /*!
  70. Load all test classes that we can "see".
  71. @result Array of initialized (and autoreleased) test case classes in an autoreleased array.
  72. */
  73. - (NSArray *)loadAllTestCases;
  74. /*!
  75. Load tests from target.
  76. @result Array of id<GHTest>
  77. */
  78. - (NSArray *)loadTestsFromTarget:(id)target;
  79. /*!
  80. See if class is of a registered test case class.
  81. */
  82. - (BOOL)isTestCaseClass:(Class)aClass;
  83. /*!
  84. Register test case class.
  85. @param aClass
  86. */
  87. - (void)registerClass:(Class)aClass;
  88. /*!
  89. Register test case class by name.
  90. @param className Class name (via NSStringFromClass(aClass)
  91. */
  92. - (void)registerClassName:(NSString *)className;
  93. /*!
  94. Format test exception.
  95. @param exception
  96. @result Description
  97. */
  98. + (NSString *)descriptionForException:(NSException *)exception;
  99. /*!
  100. Filename for cause of test exception.
  101. @param test
  102. @result Filename
  103. */
  104. + (NSString *)exceptionFilenameForTest:(id<GHTest>)test;
  105. /*!
  106. Line number for cause of test exception.
  107. @param test
  108. @result Line number
  109. */
  110. + (NSInteger)exceptionLineNumberForTest:(id<GHTest>)test;
  111. /*!
  112. Run test.
  113. @param target
  114. @param selector
  115. @param exception Exception, if set, is retained and should be released by the caller.
  116. @param interval Time to run the test
  117. @param reraiseExceptions If YES, will re-raise exceptions
  118. */
  119. + (BOOL)runTestWithTarget:(id)target selector:(SEL)selector exception:(NSException **)exception
  120. interval:(NSTimeInterval *)interval reraiseExceptions:(BOOL)reraiseExceptions;
  121. /*!
  122. Same as normal runTest without catching exceptions.
  123. */
  124. + (BOOL)runTestOrRaiseWithTarget:(id)target selector:(SEL)selector exception:(NSException **)exception interval:(NSTimeInterval *)interval;
  125. @end
  126. @protocol GHSenTestCase
  127. - (void)raiseAfterFailure;
  128. @end
  129. //! @endcond