I'm trying to dive into the quite frankly terrible world of unit testing using Xcode (such a convoluted process it seems.)
Basically I have this test class, attempting to test my Show.h class
#import <GHUnit/GHUnit.h>
#import "Show.h"
@interface ShowTest : GHTestCase { }
@end
@implementation ShowTest
- (void)testShowCreate
{
Show *s = [[Show alloc] init];
GHAssertNotNil(s,@"Was nil.");
}
@end
However when I try to build and run my tests it moans with this error: -
Undefined symbols:
"_OBJC_CLASS_$_Show", referenced from:
__objc_classrefs__DATA@0 in ShowTest.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Now I'm presuming this is a linking error. I tried following every step in the instructions located here: -
http://github.com/gabriel/gh-unit/blob/master/README.md
And step 2 of these instructions confused me: -
In the Target 'Tests' Info window, General tab:
Add a linked library, under Mac OS X 10.5 SDK section, select GHUnit.framework
Add a linked library, select your project.
Add a direct dependency, and select your project. (This will cause your application or framework to build before the test target.)
How am I supposed to add my project to the linked library list when all it accepts it .dylib, .framework and .o files?
Unit testing considerations What errors are commonly found during Unit Testing? (1) Misunderstood or incorrect arithmetic precedence, (2) Mixed mode operations, (3) Incorrect initialization, (4) Precision inaccuracy, (5) Incorrect symbolic representation of an expression.
The most scalable way to write unit tests in C is using a unit testing framework, such as: CppUTest. Unity. Google Test.
In the overall view of any unit test application, we will see that a unit test is a three-step processes. The first one is setup test or arrange test, Act test or execute unit test and Assert means verify test result with expected results. The concept of three "A"s are given below.
If the target you are testing is an application, you'll need to manually include the Show.h/m files in both your main target and your test target.
I also updated the README to reflect this:
Test
project manually. Sorry for the confusion! Having to include files in both targets is not ideal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With