2014-11-05 87 views
5

我正在开发使用Xcode 6的iOS应用程序,并试图在Xcode中运行测试套件。我可以运行测试,但没有看到我的NSLog语句输出的位置。它们不在输出面板中。Xcode iOS testsuite NSLog输出丢失

如何找到输出?

@interface ISTest : XCTestCase 
@end 

@implement ISTest 
- (void) setUp { 
    [super setUp]; 
} 

- (void) tearDown { 
    [super tearDown]; 
} 

- (void) testExample { 
    NSLog(@"Where does this go???"); 
} 

- (void) testPerformanceExample { 
    [self measureBlock^{ 
    }]; 
} 
@end 
+0

所有日志语句都应该出现在调试区域中。你可以发布一个示例测试用例吗? – JAL 2014-11-05 23:36:29

+0

@JAL调试区域在哪里? – user1165560 2014-11-06 00:22:05

+1

调试区域是Xcode中的下部视图,当您点击断点时显示控制台和范围内的变量。通过点击Xcode右上角蓝色矩形的方形按钮,确保这个视图是打开的。 – JAL 2014-11-06 14:40:29

回答

8

在Xcode的调试区域(下部视图)中检查控制台。要打开此视图,请单击Xco​​de右上角蓝色矩形的正方形按钮。

编辑:为什么downvote?日志语句出现在我的调试区域。

测试:

- (void)testLoginViewControllerViewExists { 
    NSLog(@"Testing Login View Controller"); 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Login" bundle:nil]; 
    CSLoginViewController *loginVC = [storyboard instantiateViewControllerWithIdentifier: 
             @"loginVC"]; 
    XCTAssertNotNil([loginVC view], @"loginVC should contain a view"); 
} 

输出:在测试中

Test Case '-[AppTests testLoginViewControllerViewExists]' started. 
2014-11-06 15:52:00.175 App[14870:2071450] Testing Login View Controller 
Test Case '-[AppTests testLoginViewControllerViewExists]' passed (0.001 seconds). 
+0

不要谁downvoted ...但它的工作。谢谢。 – user1165560 2014-11-09 09:57:24

+0

确保异步处理正确,否则将无法输出完成块中的任何NSLog。 – Greg 2017-06-18 09:01:09

3

日志输出不会去控制台。

如果你想看到你的日志,他们在生成输出。