iPhone UnitTesting UITextField值和otest错误133 [英] iPhone UnitTesting UITextField value and otest error 133

查看:35
本文介绍了iPhone UnitTesting UITextField值和otest错误133的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UITextFields是否不是要成为LogicTests的一部分,而是要成为ApplicationTest目标的一部分?

Are UITextFields not meant to be part of the LogicTests and instead part of the ApplicationTest target?

我有一个工厂类,负责创建和返回(iPhone)UITextField,并且正在尝试对其进行单元测试.它是我的逻辑测试目标的一部分,当我尝试构建和运行测试时,出现以下构建错误:

I have a factory class that is responsible for creating and returning an (iPhone) UITextField and I'm trying to unit test it. It is part of my Logic Test target and when I try to build and run the tests, I get a build error about:

/Developer/Tools/RunPlatformUnitTests.include:451:0试验台'/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk/'开发人员/usr/bin/otest'异常退出并显示代码133(它是可能已崩溃).

/Developer/Tools/RunPlatformUnitTests.include:451:0 Test rig '/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk/ 'Developer/usr/bin/otest' exited abnormally with code 133 (it may have crashed).

在构建窗口中,它指向以下行:"RunPlatformUnitTests.include"

In the build window, this points to the following line in: "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

推荐答案

这是

为什么要实例化iPhone单元测试中的UIFont导致崩溃?

这是回溯:

#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:] ()
...

这篇关于iPhone UnitTesting UITextField值和otest错误133的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆