Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tried a couple different approaches this morning:</p> <ol> <li><p>Using a <code>UIDevice</code> category that is only linked to my test target. In that category I would override <code>currentDevice</code> with a <code>partialMock</code> implementation (<code>OCMock</code>) and stub the necessary method so that it returns Pad or Phone forcedly to my specifics tests. It should have work, but its very difficult to mess with classes such as <code>UIDevice</code> or <code>UIApplication</code>, the simulator often crashes which is a bad sign.</p></li> <li><p><code>#undef UI_INTERFACE_IDIOM()</code> and <code>#define</code> it on my test <code>.pch</code>. Pointing <code>UI_INTERFACE_IDIOM()</code> implementation in the test to a singleton instance of my own, that I could set to Pad or Phone accordingly. That worked, but the main problem is that when you run the tests the simulator also goes up ( application tests that is ) so if you are running your tests on the iPad, your test will pass, but other parts of the simulator will fail because of the contraditory responses it gets from <code>UI_INTERFACE_IDIOM()</code> (one of such is the loading of nib's specific to iPhone if you are in a universal app environment )</p></li> <li><p>I think this is the best approach. As everything in computer science, just put another layer in =) Instead of your code using <code>UI_INTERFACE_IDIOM()</code> to assess if it is on a Pad or Phone device, encapsulate this logic in a object that you can mock during your tests. That way <code>UI_INTERFACE_IDIOM()</code> will still be available to the rest of the simulator. Your production code will actually rely on it, but your tests will rely on a stubbed implementation that can respond as expected in your tests.</p></li> </ol> <p>If you want to, I can share some codes regarding this matter. And yes, this is a weary one!</p> <p>How you managed to workaround this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload