user1165560
user1165560

Reputation: 341

Xcode iOS testsuite NSLog output missing

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

Upvotes: 12

Views: 9533

Answers (3)

C. Kontos
C. Kontos

Reputation: 1258

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]);

Upvotes: 3

Abizern
Abizern

Reputation: 150745

Log output in tests does not go to the console.

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

Upvotes: 5

JAL
JAL

Reputation: 42489

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).

Upvotes: 8

Related Questions