PageRenderTime 34ms CodeModel.GetById 19ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

C++ Header | 79 lines | 21 code | 11 blank | 47 comment | 0 complexity | 483eba82d38b158fc3c702059dcd53b0 MD5 | raw file
 2//  GTMUnitTestDevLog.h
 4//  Copyright 2008 Google Inc.
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
19#import "GTMDefines.h"
20#import <Foundation/Foundation.h>
22// GTMUnitTestDevLog tracks what messages are logged to verify that you only
23// log what you expect to log during the running of unittests. This allows you
24// to log with impunity from your actual core implementations and still be able
25// to find unexpected logs in your output when running unittests.
26// In your unittests you tell GTMUnitTestDevLog what messages you expect your
27// test to spit out, and it will cause any that don't match to appear as errors
28// in your unittest run output. You can match on exact strings or standard 
29// regexps.
30// Set GTM_SHOW_UNITTEST_DEVLOGS in the environment to show the logs that that
31// are expected and encountered.  Otherwise they aren't display to keep the
32// unit test results easier to read.
34@interface GTMUnitTestDevLog : NSObject
35// Log a message
36+ (void)log:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
37+ (void)log:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(1,0);
39// Turn tracking on/off
40+ (void)enableTracking;
41+ (void)disableTracking;
42+ (BOOL)isTrackingEnabled;
44// Note that you are expecting a string that has an exact match. No need to
45// escape any pattern characters.
46+ (void)expectString:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
48// Note that you are expecting a pattern. Pattern characters that you want
49// exact matches on must be escaped. See [GTMRegex escapedPatternForString].
50// Patterns match across newlines (kGTMRegexOptionSupressNewlineSupport) making
51// it easier to match output from the descriptions of NS collection types such
52// as NSArray and NSDictionary.
53+ (void)expectPattern:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
55// Note that you are expecting exactly 'n' strings
56+ (void)expect:(NSUInteger)n 
57    casesOfString:(NSString *)format, ... NS_FORMAT_FUNCTION(2,3);
59// Note that you are expecting exactly 'n' patterns
60+ (void)expect:(NSUInteger)n 
61    casesOfPattern:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3);
62+ (void)expect:(NSUInteger)n 
63    casesOfPattern:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(2,0);
65// Call when you want to verify that you have matched all the logs you expect
66// to match. If your unittests inherit from GTMTestcase (like they should) you
67// will get this called for free.
68+ (void)verifyNoMoreLogsExpected;
70// Resets the expected logs so that you don't have anything expected.
71// In general should not be needed, unless you have a variable logging case
72// of some sort.
73+ (void)resetExpectedLogs;
76// Does the same as GTMUnitTestDevLog, but the logs are only expected in debug.
77// ie-the expect requests don't count in release builds.
78@interface GTMUnitTestDevLogDebug : GTMUnitTestDevLog