代码来自ClassMessage:
-(void)showMessage:(Message*) msg
{
if( msg == nil )
{
return;
}
UIAlertView* alertView;
if(msg.url)
{
alertView = [[UIAlertView alloc] initWithTitle:msg.title
message:msg.message
delegate:self
cancelButtonTitle:msg.buttonLabel1
otherButtonTitles:msg.buttonLabel2
, nil];
}
else
{
alertView = [[UIAlertView alloc] initWithTitle:msg.title
message:msg.message
delegate:self
cancelButtonTitle:msg.buttonLabel1
otherButtonTitles:nil];
}
[alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
}
为上述方法编写单元测试用例!
-(void)testShowMessageMessageURL{
Message *testMessage = [[Message alloc] init];
testMessage.messageId = 1000 ;
testMessage.message = @"Error message";
testMessage.title = @"Error Title";
testMessage.url = @"http://.……….";
testMessage.buttonLabel1 = @"OK";
testMessage.buttonLabel2 = @"Cancel";
testMessage.buttonLabel2 = nil;
@try {
ClassMessage *testClass = [[ClassMessage alloc]init];
if(testMessage.url != nil){
STAssertNoThrow([testClass showMessage:testMessage],@"Should Pass ");
}
}
@catch (NSException *exception) {
NSLog(@"Exception Name %@, Exception Description %@",[exception name],[exception description]);
STFail(@"Should not caught Exception");
}
}
应用暂停
CoreFoundation`__HALT:
0xa40880: int3
0xa40881: nopw %cs:(%eax,%eax)
Thread 1: EXC_BreakPoint(code = EXC_i386_BPT,subcode = 0*0)
单击“继续执行程序”
后我收到了错误消息 错误消息是:
[testClass showMessage:testMessage] raised -[_NSCFType pointSize]: unrecognized selector sent to instance should not throws any exception.
在覆盖我的测试用例时,我确实遇到了这个问题。
任何人都建议我做错了我的测试案例? @Thanks提前