I'm trying to set up unit testing for my iPhone application. I followed the Apple Unit Testing documentation through and that woked fine, but as soon as I added another class in to that test, I get the following error:
"_OBJC_CLASS_$_RootViewController", referenced from:
__objc_classrefs__DATA@0 in AppDelegateTests.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
The application itself is a basic navigation app with Core data for data storage.
The unit test is as follows:
#import <SenTestingKit/SenTestingKit.h>
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "HSStabilityAppAppDelegate.h"
#import "RootViewController.h"
@interface AppDelegateTests : SenTestCase {
HSStabilityAppAppDelegate *appDelegate;
}
@end
@implementation AppDelegateTests
// all code under test must be linked into the Unit Test bundle
#pragma mark -
#pragma mark Set up and tearDown
#if APPLICATION_TESTS
- (void) setUp {
appDelegate = (HSStabilityAppAppDelegate *)[[UIApplication sharedApplication] delegate];
STAssertNotNil(appDelegate, @"Cannot find the application delegate.");
}
- (void) tearDown {
[appDelegate release];
}
#else
#endif
#pragma mark -
#pragma mark Tests
#if APPLICATION_TESTS
- (void) testRootViewIsOnTop {
id topViewControllerClass = [[appDelegate.navigationController topViewController] class];
id rootViewControllerClass = [RootViewController class];
STAssertEquals(topViewControllerClass, rootViewControllerClass, @"Root view controller was not the top class");
}
#endif
@end
If I comment out the id rootViewControllerClass line then the program links correctly. Also, this only occurs when building against the device target, I don't have any problems if building against the simulator (probably given that application tests don't work on the simulator).
Can anyone help solve this basic and very infuriating problem?