Note that there are some explanatory texts on larger screens.

plurals
  1. POisMemberOfClass returns no when ViewController is instantiated from UIStoryboard
    text
    copied!<p>I have an OCUnit Test class: PatientTestViewControllerTests. Below is the interface:</p> <pre><code>@interface PatientTestViewControllerTests : SenTestCase @property (nonatomic, strong) PatientTestViewController *testController; @end </code></pre> <p>and setUp:</p> <pre><code>- (void) setUp { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Testing" bundle:nil]; self.testController = [storyboard instantiateInitialViewController]; } </code></pre> <p>The 'Testing' storyboard is the only storyboard in my app, and is set as the app's main storyboard. The PatientTestViewController is set as the storyboard's only view controller.</p> <p>I have one test in my test class:</p> <pre><code>- (void) testInitialTestingStoryboardViewIsPatientTest { STAssertTrue([self.testController isMemberOfClass:[PatientTestViewController class]], @"Instead of the %@, we have %@",[PatientTestViewController class], [self.testController class]); } </code></pre> <p>This test fails with the following log message:</p> <p>error: -[PatientTestViewControllerTests testInitialTestingStoryboardViewIsPatientTest] : "[self.testController isMemberOfClass:[PatientTestViewController class]]" should be true. Instead of the <strong>PatientTestViewController</strong>, we have <strong>PatientTestViewController</strong></p> <p>How can this be? Since </p> <p><code>[self.testController isMemberOfClass:[PatientTestViewController class]]</code> </p> <p>is apparently false, how can the test log say that both </p> <p><code>[self.testController class]</code> and <code>[PatientTestViewController class]</code></p> <p>look the same? </p> <p>Additional Info:</p> <ul> <li>using <code>[self.testController isKindOfClass:[PatientTestViewController class]]</code> in the test also fails</li> <li><p>using <code>[self.testController class] == [PatientTestViewController class]</code> fails also.</p></li> <li><p>using <code>[self.testController isKindOfClass:[UIViewController class]]</code> PASSES.</p></li> <li>using <code>[self.testController isMemberOfClass:[UIViewController class]]</code> FAILS.</li> </ul>
 

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