2009-12-29 2 views
3

UITextField는 LogicTests의 일부가 아니며 ApplicationTest 대상의 일부입니까?iPhone UnitTesting UITextField 값 및 otest 오류 133

저는 (iPhone) UITextField를 생성하고 반환하는 팩토리 클래스를 가지고 있고 그것을 단위 테스트하려고합니다. 그것은 나의 논리 테스트 대상의 일부이며 내가 구축하고 테스트를 실행하려고 할 때, 나는 약 빌드 오류가 발생합니다 : '

/Developer/Tools/RunPlatformUnitTests.include:451:0 테스트 장비 /개발자/플랫폼/iPhoneSimulator.platform/Developer/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 
+0

UITextFields도 LogicTests 나를 위해 실패의 원인이되는 당신의 관측은 정확합니다. - UITextField는 LogicTests의 일부가 아닙니다. –

답변

0

분명히, 당신은 가정되지 않습니다. 논리 테스트에 UITextField를 포함 시키지만 응용 프로그램 테스트로 이동하십시오.

+1

이것이 효과가 있다면, 답을 수락으로 표시 하시겠습니까? – Pops

0

그래서 나는 같은 문제가 있습니다 ..... 어떤 해결책이 있습니까?

나는 그것을 해결하기 위해 DummyUITextField 클래스를 만들고이를 UITextField가 필요한 클래스에 삽입하는 방법을 설명합니다. (그것의 조롱과 같은, 그러나 모의는 틀린 용어 일 것입니다).

@interface DummyUITextField : UIView { 

NSString *text; 

} 

@property (nonatomic, retain) NSString *text; 

@end 

다음으로이 클래스에 필요한 다른 메소드를 추가 할 수 있습니다.

그러나 테스트중인 코드가 인터페이스 작성기를 사용하는 대신 자신의 UITextField를 만드는 경우 다른 솔루션을 찾아야합니다.

감사 데이브

1

이는 역 추적

여기 Why does instantiating a UIFont in an iphone unit test cause a crash?

의 중복 것입니다 : 그것은 나타납니다, 그래서

#0 0x004899d1 in __HALT() 
#1 0x003d576d in _CFRuntimeCreateInstance() 
#2 0x00c57ef0 in GSFontCreateWithName() 
#3 0x03fccc72 in +[UIFont systemFontOfSize:]() 
#4 0x03f80766 in +[UILabel defaultFont]() 
#5 0x03f82ec4 in -[UILabel _commonInit]() 
#6 0x03f80d3a in -[UILabel initWithFrame:]() 
#7 0x03efbde8 in -[UITextField createTextLabelWithTextColor:]() 
#8 0x03f03e1a in -[UITextField initWithFrame:]() 
#9 0x00c52d75 in +[TextFieldFactory createTextField:] (self=0xc5308c, _cmd=0x8400b50, isSecureField=1 '\001') at /Users/dmaclach/Desktop/test/Classes/untitled2.m:19 
#10 0x00c52c98 in -[TextFieldFactoryTests testUITextField_NotASecureField] (self=0x2161bf0, _cmd=0xc52dfe) at /Users/dmaclach/Desktop/test/Classes/untitled.m:26 
#11 0x0043642d in __invoking___() 
#12 0x00436301 in -[NSInvocation invoke]() 
#13 0x20104632 in -[SenTestCase invokeTest]() 
#14 0x20104d07 in -[SenTestCase performTest:]() 
...