我有一个OCUnit Test类:PatientTestViewControllerTests.以下是界面:
@interface PatientTestViewControllerTests : SenTestCase
@property (nonatomic, strong) PatientTestViewController *testController;
@end
Run Code Online (Sandbox Code Playgroud)
和setUp:
- (void) setUp
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Testing" bundle:nil];
self.testController = [storyboard instantiateInitialViewController];
}
Run Code Online (Sandbox Code Playgroud)
"测试"故事板是我应用程序中唯一的故事板,并被设置为应用程序的主要故事板.PatientTestViewController被设置为故事板的唯一视图控制器.
我的测试课中有一个测试:
- (void) testInitialTestingStoryboardViewIsPatientTest
{
STAssertTrue([self.testController isMemberOfClass:[PatientTestViewController class]], @"Instead of the %@, we have %@",[PatientTestViewController class], [self.testController class]);
}
Run Code Online (Sandbox Code Playgroud)
此测试失败,并显示以下日志消息:
错误: - [PatientTestViewControllerTests testInitialTestingStoryboardViewIsPatientTest]:"[self.testController isMemberOfClass:[PatientTestViewController class]]"应为true.取而代之的是的PatientTestViewController,我们有PatientTestViewController
怎么会这样?以来
[self.testController isMemberOfClass:[PatientTestViewController class]]
显然是错误的,测试日志怎么能说两者都有
[self.testController class] 和 [PatientTestViewController class]
看起来一样?
附加信息:
[self.testController isKindOfClass:[PatientTestViewController class]]测试也失败使用[self.testController class] == [PatientTestViewController …