2013-08-13 4 views
0

В Xcode, я пытаюсь сделать блок тестирования с использованием GHUnit и OCMock, как описано здесь:Модульное тестирование в Xcode (Использование GHUnit и OCMock)

Unit Testing Xcode

и настроить методы, как descibed здесь:

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:

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)

Но когда я удалить строку

 login = [[RS_LoginRSViewController alloc]init]; 

из

- (void)setUpClass 

метод Затем он работает успешно. Почему я получаю эту ошибку? Любая помощь будет оценена по достоинству.

+0

Эта ошибка свидетельствует о том, что RS_LoginRSViewController не был/не был скомпилирован для симулятора. Успешно ли выполняются ваши тесты на устройстве? –

+1

@Ben Flynn: Я разрешил ошибки, добавив фреймворки и библиотеку для создания фаз. – Ponting

ответ

0

Я разрешил ошибки, добавив необходимые файлы, фреймворки и библиотеку, чтобы построить фазы целевой цели проекта.

Смежные вопросы