【发布时间】:2013-11-04 08:50:31
【问题描述】:
我想使用 OCUnit 来测试我的工作。 但我的一种方法是这样的:
- (BOOL)testThread
{
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(thread) object:nil];
[thread start];
return YES;
}
- (void)thread
{
NSLog(@"thread**********************");
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(thread2) object:nil];
[thread start];
}
- (void)thread2
{
NSLog(@"thread2**********************");
}
现在我要运行测试:
- (void)testExample
{
testNSThread *_testNSThread = [[testNSThread alloc] init];
STAssertTrue([_testNSThread testThread], @"test");
}
在我的测试用例中 但是thread2没有运行 所以我该怎么做?第三季!
【问题讨论】:
-
我知道这只是一个代码示例,与您的问题无关,但在命名类时不要使用 thisNotation 而是使用 ThisNotation - 第一个字母应始终为大写。此外,局部变量名中的下划线也不合适,它通常用于实例变量。