1
單元測試正在通過此處的bucketload來處理謙卑。我試圖運行我的BannerAdViewController級測試,但達到以下線的時候一切都轟然倒塌:OCUnit在創建UITextView時崩潰
UITextView *buyAppTextView = [[UITextView alloc] initWithFrame:CGRectMake(8, 2, 304, 50)];
控制檯輸出如下:
-[__NSCFType markupDescription]: unrecognized selector sent to instance 0x1bc2de0
這是它到達的方法發生崩潰之前:
-(void)setup{
_bannerFrame = [self frameRectForBannerAd];
_bannerWrapperFrame = [self frameRectForBannerWrapperFrame];
UITextView *buyAppTextView = [[UITextView alloc] initWithFrame:CGRectMake(8, 2, 304, 50)];
[buyAppTextView setText:@"some text"];
[buyAppTextView setTextColor:[UIColor blackColor]];
[buyAppTextView setFont:[UIFont systemFontOfSize:10]];
[buyAppTextView setAutoresizingMask:UIViewContentModeScaleAspectFit];
[buyAppTextView setUserInteractionEnabled:NO];
_placeHolderBanner = [[UIView alloc] initWithFrame:_bannerFrame];
[_placeHolderBanner setBackgroundColor:[UIColor whiteColor]];
[[_placeHolderBanner layer] setBorderColor:[UIColor blackColor].CGColor];
[[_placeHolderBanner layer] setBorderWidth:1.0];
[_placeHolderBanner addSubview: buyAppTextView];
[[self view] setFrame:_bannerWrapperFrame];
[[self view] setBackgroundColor:[UIColor clearColor]];
[[self view] addSubview: _placeHolderBanner];
_iAdBanner = [[ADBannerView alloc] initWithFrame:CGRectZero];
[[self view] addSubview: _iAdBanner];
_iAdBanner.delegate = self;
_iAdBanner.hidden = YES;
}
如果我註釋掉了與buyAppTextView有關的所有操作,測試運行正常。 (是的,如果您想知道,測試平臺與UIKit鏈接)。
哦,測試類看起來像這樣
#import "NorBannerAdViewTests.h"
#import "NORBannerAdViewController.h"
@implementation NorBannerAdViewTests
NORBannerAdViewController *_adViewController;
- (void)setUp{
[super setUp];
_adViewController = [[NORBannerAdViewController alloc] init];
}
- (void)tearDown{
[super tearDown];
[_adViewController release];
}
-(void) testThatFrameRectForBannerAdWrapperDoesNotReturnZero{
CGRect receivedFrame = [_adViewController frameRectForBannerWrapperFrame];
STAssertFalse((CGRectIsEmpty(receivedFrame)), @"receivedFrame should not be zero");
}
-(void) testThatFrameRectForBannerAdDoesNotReturnZero{
CGRect receivedFrame = [_adViewController frameRectForBannerAd];
STAssertFalse((CGRectIsEmpty(receivedFrame)), @"receivedFrame should not be zero");
}
@end
你有沒有設置異常斷點,所以你可以看到誰打電話呢? –
Yup 11 [SenTestCase invokeTest] - > 10 [NORBannerAdViewTests設置] - > 9 [NORBannerAdViewController init] - > 8 [NORBannerAdView設置] - > 7 [UITextView initWithFrame:] | 0_HALT –
'initWithFrame:'調用沒有問題,所以我懷疑這是一個虛假的提示。 –