11

I'm developing an iOS app using Xcode 6 and am trying to run a test suite in Xcode. I can run the test but I don't see where my NSLog statements output. They are not in the output panel.

How do I find the output?

@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
JAL
  • 41,701
  • 23
  • 172
  • 300
user1165560
  • 331
  • 4
  • 21
  • All log statements should appear in the debugging area. Can you post an example test case? – JAL Nov 05 '14 at 23:36
  • @JAL Where is the debugging area? – user1165560 Nov 06 '14 at 00:22
  • 1
    The debugging area is the lower view in Xcode that shows the console and the variables in scope when you hit a breakpoint. Make sure this view is open by clicking the square button with the blue rectangle on the bottom in the top-right corner of Xcode. – JAL Nov 06 '14 at 14:40
  • Somehow, I can see the output in All Output now... Don't know what happened before.... Thanks. – user1165560 Nov 06 '14 at 19:42
  • I have added my answer below. Feel free to mark it as accepted if it helped you. – JAL Nov 06 '14 at 19:57

3 Answers3

8

Check console in the debugging area (the lower view) in Xcode. To open this view, click the square button with the blue rectangle on the bottom in the top-right corner of Xcode.

Edit: Why the downvote? Log statements appear in the debugging area for me.

Test:

- (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");
}

Output:

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).
JAL
  • 41,701
  • 23
  • 172
  • 300
  • 1
    Make sure that async is handled correctly otherwise any NSLog's in a completion block won't output. – Greg Jun 18 '17 at 09:01
  • 1
    The OP is looking for the NSLog() statements within his application, not the test code. What you'd normally see when running a debug, not test. – Jeff Jan 06 '20 at 08:54
5

Log output in tests does not go to the console.

If you want to see your logs, they are in the build output.

JAL
  • 41,701
  • 23
  • 172
  • 300
Abizern
  • 146,289
  • 39
  • 203
  • 257
3

If you want to see your messages or your strings in your tests being printed on the output console use printf and not NSLog

Example: printf("%s", [yourNSString UTF8String]);

C. Kontos
  • 1,198
  • 12
  • 21