В Xcode, я пытаюсь сделать блок тестирования с использованием GHUnit и OCMock, как описано здесь:Модульное тестирование в Xcode (Использование GHUnit и OCMock)
и настроить методы, как descibed здесь:
Но получил ошибку в этом методе
- (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
метод Затем он работает успешно. Почему я получаю эту ошибку? Любая помощь будет оценена по достоинству.
Эта ошибка свидетельствует о том, что RS_LoginRSViewController не был/не был скомпилирован для симулятора. Успешно ли выполняются ваши тесты на устройстве? –
@Ben Flynn: Я разрешил ошибки, добавив фреймворки и библиотеку для создания фаз. – Ponting