0
在我的应用我执行单元测试方式如下:的iOS单元测试运行失败
.h文件中:
@interface MyAppTests : SenTestCase
{
SMAppDelegate* _appDelegate;
SMMenuViewController* _menuViewController;
UIView* _mainView;
}
.m文件
- (void)setUp
{
[super setUp];
_appDelegate = [[UIApplication sharedApplication]delegate];
_menuViewController = [[SMMenuViewController alloc]init];
_mainView = [_menuViewController view]; // to force the view to load
}
- (void)tearDown
{
// Tear-down code here.
_mainView = nil;
_menuViewController = nil;
_appDelegate = nil;
[super tearDown];
}
- (void)testMenuViewisNotNil
{
STAssertNotNil(_menuViewController, @"menuViewController is nil");
}
当我运行应用程序,它运行正常,但是当我测试它时出现以下错误:
主题1:EXC_BREAKPOINT(代码= EXC_I386_BPT,子码=为0x0)
它指向这一行的viewDidLoad()
messageTextView = [[UITextView alloc]init];
messageTextView在.h文件中声明,它不与接口Builder创建,我用addSubview方法将它添加到视图中。我宣布这样的:
@interface SMMenuViewController : UIViewController <UITextFieldDelegate>
{
}
@property (strong, nonatomic) UITextView *messageTextView;
messageTextView得到合成,并在viewDidUnload我“无”了。我仍然不知道为什么在单元测试中失败。
有谁能告诉我为什么?
任何帮助非常感谢!
真诚,
佐利