Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PhotosViewControllerTests failed #1

Open
phamquy opened this issue Apr 2, 2014 · 2 comments
Open

PhotosViewControllerTests failed #1

phamquy opened this issue Apr 2, 2014 · 2 comments

Comments

@phamquy
Copy link

phamquy commented Apr 2, 2014

Just clone the source code, update submodule, and run the test
Note: the app is built and run normally

@SpaceButler
Copy link

I've had the same issue. It errors out on the line:

UIView *view = photosViewController.view;

Giving the error:

test failure: -[PhotosViewControllerTests testNibLoading] failed: OCMockObject[UINavigationController]: expected method was not invoked: pushViewController:<OCMBlockConstraint: 0xf7521d0> animated:YES

However, the test will run and "pass" if you move these lines:

    // Trigger view did load:
    UIView *view = photosViewController.view;
    STAssertNotNil(view, @"");

to immediately after the initial creation of the PhotosViewController object. But, being new to objective C and OCMock, I'm not sure if that invalidates the test.

Just from the above, it seems at first blush like once the [[mockNavController expect] pushViewController] call is made, the testing framework expects the very next message to photosViewController to cause -pushViewController to be called, and then it errors out when the read of photosViewController.view fails to do that. But I'm still too new to this to feel sure that that's really what's going on. It seems like it would be an awkward limitation on a unit testing framework.

@0oneo
Copy link

0oneo commented Apr 21, 2014

@phamquy @SpaceButler the issue is caused by -[UINavigationController _didGainChildScrollView] call, the mock object did not provide stub for that method. so the mock object just forward that call, the default implementation of forwarding just throw an exception.

dymv pushed a commit to dymv/issue-1-lighter-view-controllers that referenced this issue May 11, 2015
* Creating partial mock for navigation controller. This closes objcio#1
* Updated ocmock submodule
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants