0

xcode では、ここで説明されているように、GHUnit と OCMock を使用して単体テストを実行しようとしています。

Xcode の単体テスト

ここで説明されているように、メソッドをセットアップします。

GHUnitTestCase

しかし、このメソッドでエラーが発生しました

  • (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

メソッドの場合、正常に実行されます。このエラーが発生するのはなぜですか? どんな助けでも大歓迎です。

4

1 に答える 1

0

テスト対象のプロジェクトのビルドフェーズに必要なファイル、フレームワーク、ライブラリを追加してエラーを解決しました。

于 2013-08-16T05:50:35.930 に答える