0

my question is that I am trying to test some stuff from SenTesking Kit.

-(void)testStoryboard {
    storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    STAssertNotNil(storyBoard, @"Can't access the storyboard");
}

I have also added the UIMainStoryboardFile to the DemoTests.plist but am getting this kind of error:

error: testStoryboard (DemoTests) failed: Could not find a storyboard named 'MainStoryboard' 
in bundle 
NSBundle</Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/usr/bin> (loaded)

1 Answers1

1

I think you're going to need to be more specific about the bundle here. When you pass nil for a bundle like this, it means "use the main bundle", but if I recall correctly the main bundle when running tests will be the test harness applications bundle and not your code. I think you need to make sure that the storyboard is being included as a resource in the testing target and then you need to explicitly specify in the test that the storyboard resource is to be loaded from the your test target bundle and not the main bundle.

EDIT: Typically a good way to do this might be to pass [NSBundle bundleForClass: [MyClassThatIKnowIsInTheRightBundle class]].

ipmcc
  • 29,581
  • 5
  • 84
  • 147
  • Thanks for your answer, I was already checking this one over some resource. What I found is that I should somehow clearly specify how to use the same bundle. Any ideas what I should put instead of nil? – Dmitry Preobrazhenskiy Feb 12 '12 at 14:24
  • @Dmitry Preobrazhenskiy: Updated the answer with an idea for that. – ipmcc Feb 12 '12 at 15:07
  • error Undefined symbols for architecture i386: "_OBJC_CLASS_$_DemoAppDelegate", referenced from: objc-class-ref in DemoTests.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle bundleForClass:[DemoAppDelegate class]]]; – Dmitry Preobrazhenskiy Feb 12 '12 at 15:40
  • The that class isn't getting included in the testing bundle. Pick something you know for SURE is in the testing bundle like, say, one of the classes you're testing. – ipmcc Feb 12 '12 at 20:07