xcode では、ここで説明されているように、GHUnit と OCMock を使用して単体テストを実行しようとしています。
ここで説明されているように、メソッドをセットアップします。
しかし、このメソッドでエラーが発生しました
- (void)setUpClass { }
以下のようにViewControllerオブジェクトを初期化すると:
#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
しかし、Apple Mach-O Linker Error としてエラーが発生しました:
アーキテクチャ i386 の未定義シンボル: "_OBJC_CLASS_$_RS_LoginRSViewController"、参照元: SampleTestCase.o ld の objc-class-ref: アーキテクチャ i386 のシンボルが見つかりません。呼び出しを見るために)
しかし、行を削除すると
login = [[RS_LoginRSViewController alloc]init];
から
- (void)setUpClass
メソッドの場合、正常に実行されます。このエラーが発生するのはなぜですか? どんな助けでも大歓迎です。