Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

-slidingViewController returns nil during unit tests #269

Closed
s73v3r opened this issue Dec 31, 2013 · 3 comments
Closed

-slidingViewController returns nil during unit tests #269

s73v3r opened this issue Dec 31, 2013 · 3 comments

Comments

@s73v3r
Copy link

s73v3r commented Dec 31, 2013

I installed ECSlidingViewController using Cocoapods. When running unit tests, any view controller that accesses the -slidingViewController property ends up failing because -slidingViewController returns nil. This happens despite the fact that -isKindOfClass and NSStringFromClass both agree that the view controller should be an ECSlidingViewController.

@enriquez
Copy link
Member

enriquez commented Jan 7, 2014

I tried this out and it looks like Cocoapods doesn't link the test target for some reason. I was able to fix it by telling Cocoapods to link with the test target along with the regular target:

link_with ['MyApp', 'MyAppTests']

@enriquez enriquez closed this as completed Jan 7, 2014
@backofthecup
Copy link

This still doesn't work. I've tried everything to get this to work:
Added the link_with:

link_with 'PatientMobile', 'PatientMobileTests'
pod 'AFNetworking', '~> 2.4'
pod 'ECSlidingViewController', '~> 2.0.3'

Verified that there are no source files in my test target build phase:
buildphase

My tests are crashing on this line of code because self.slidingViewController is nil:

 [self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];

BTW, I can use the AFNetworking library (also a POD) without any issues in my Tests.

I really like this control, but if it breaks my unit tests, I'll have to use something else.

Do you have any suggestions?

@backofthecup
Copy link

@enriquez
This looks like a Test/POD issue returning nil for isKindOfClass method. I finally got this working when I changed my Profile to read:

target 'PatientMobile' do
    pod 'AFNetworking', '~> 2.4'
    pod 'ECSlidingViewController', '~> 2.0.3'
end

target 'PatientMobileTests'  do
    # this pod is not used by PatientMobileTests, but we need something here to ensure we properly link cocoapods to the PatientMobileTests target
    pod 'OCMock', :head
end

link_with 'PatientMobile', 'PatientMobileTests'


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants