UITextFields是不是要成爲LogicTests的一部分,而不是ApplicationTest目標的一部分?iPhone UnitTesting UITextField值和等值線錯誤133
我有一個工廠類負責創建和返回(iPhone)UITextField,我試圖單元測試它。這是我的邏輯測試目標的一部分,當我嘗試建立並運行測試,我得到生成錯誤有關:
/Developer/Tools/RunPlatformUnitTests.include:451:0 試驗檯 「/開發人員/平臺/ iPhoneSimulator.platform /開發人員/ SDKs/iPhoneSimulator3.1.2.sdk/ '開發人員/ usr/bin/otest' 異常退出代碼133(它 可能已崩潰)。
在構建窗口,這點到下面一行: 「RunPlatformUnitTests.include」
RPUTIFail ${LINENO} "Test rig '${TEST_RIG}' exited abnormally with code ${TEST_RIG_RESULT} (it may have crashed)."
我的單元測試是這樣的:
#import <SenTestingKit/SenTestingKit.h>
#import <UIKit/UIKit.h>
// Test-subject headers.
#import "TextFieldFactory.h"
@interface TextFieldFactoryTests : SenTestCase {
}
@end
@implementation TextFieldFactoryTests
#pragma mark Test Setup/teardown
- (void) setUp {
NSLog(@"%@ setUp", self.name);
}
- (void) tearDown {
NSLog(@"%@ tearDown", self.name);
}
#pragma mark Tests
- (void) testUITextField_NotASecureField
{
NSLog(@"%@ start", self.name);
UITextField *textField = [TextFieldFactory createTextField:YES];
NSLog(@"%@ end", self.name);
}
類我試圖測試:
// Header file
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TextFieldFactory : NSObject {
}
+(UITextField *)createTextField:(BOOL)isSecureField;
@end
// Implementation file
#import "TextFieldFactory.h"
@implementation TextFieldFactory
+(UITextField *)createTextField:(BOOL)isSecureField
{
// x,y,z,w are constants declared else where
UITextField *textField = [[[UITextField alloc]
initWithFrame:CGRectMake(x, y, z, w)]
autorelease];
// some initialization code
return textField;
}
@end
UITextFields也造成LogicTests失敗對我來說,這樣看來,你的觀察是正確的 - UITextFields並不意味着是LogicTests的一部分。 – 2010-04-08 14:13:42