In xcode,I am trying to do unit Testing using GHUnit and OCMock as described here :
And Set Up methods as descibed here :
But got the error in this method
- (void)setUpClass { }
when I initialize my ViewController Object as below :
#import <GHUnitIOS/GHUnit.h>
#import <OCMock/OCMock.h>
#import "RS_LoginRSViewController.h"
@interface SampleLibTest : GHTestCase
{
RS_LoginRSViewController * login;
}
@end
@implementation SampleLibTest
// Run before each test method
- (void)setUp { }
// Run after each test method
- (void)tearDown { }
// Run before the tests are run for this class
- (void)setUpClass
{
GHTestLog(@"Log with a test with the GHTestLog(...) for test specific logging.");
login = [[RS_LoginRSViewController alloc]init];
}
// Run before the tests are run for this class
- (void)tearDownClass { }
// Tests are prefixed by 'test' and contain no arguments and no return value
- (void)testA {
GHTestLog(@"Log with a test with the GHTestLog(...) for test specific logging.");
}
// Override any exceptions; By default exceptions are raised, causing a test failure
- (void)failWithException:(NSException *)exception { }
@end
But got error as Apple Mach-O Linker Error :
Undefined symbols for architecture i386: "_OBJC_CLASS_$_RS_LoginRSViewController", referenced from: objc-class-ref in SampleTestCase.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
But when I remove line
login = [[RS_LoginRSViewController alloc]init];
from
- (void)setUpClass
method then It runs successfully.Why I am getting this error ? Any help will be appreciated.
I resolved errors by adding necessary files , frameworks and library to build phases of project target of testing.