cedarbdd / cedar

BDD-style testing using Objective-C
http://groups.google.com/group/cedar-discuss
1.19k stars 140 forks source link

View Controller size class is unspecified when loaded through test #362

Closed blladnar closed 8 years ago

blladnar commented 8 years ago

I'm trying to write some view controller tests that differ in behavior between iPhone and iPad in a universal app. When running the tests, the horizontal size class returned is always UIUserInterfaceSizeClassUnspecified. With XCTest, it returns the correct size class depending on whether I run it on an iPhone or an iPad.

tjarratt commented 8 years ago

Hey Randall, I'm sorry you're having this issues.

You mentioned this doesn't occur when you run your tests with XCTest -- how are you running your tests with Cedar? Do you have a spec suite that runs your tests in a separate application, or are you using a test bundle?

My expectation is that this should work with Cedar when running in a test bundle. In that case, your real application starts up in the simulator, and there is a real window backing it.

If your tests are setup as a stand-alone spec suite, I imagine you may have to do some additional setup to make this work. You may need to create a UIWindow and set your view controller as the root view controller on it.

tjarratt commented 8 years ago

@blladnar did that help? Still having issues? If you have a small reproducible test case, I'd love to dig into this more.

I've definitely encountered this in the past using Cedar and found it difficult to work around, but possible with enough work. Would love to help you out if I can.