I'm new to Objective-C and XCode and consider me mentally challenged when discussing compiled languages in general. I have no idea how linkers work and the amount of build settings in every IDE I've had the discomfort of working with simply scares me.
I've started learning ObjC a few days ago and of course I started with a Console Application project. Everything is fine so far, but I have a Ruby / Rails background which made me want to immediately understand how to set up even the most basic TDD environment in XCode5.
I used this official dev doc but it's less than thorough. Taking the trial and error path I simply added a XCTest target to the Project and then added a Test Case Class, testing my Fraction
class:
#import <XCTest/XCTest.h>
#import "Fraction.h"
@interface FractionTest : XCTestCase
@end
@implementation FractionTest
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
[super tearDown];
}
- (void)testExample
{
Fraction *fraction = [Fraction new];
}
@end
When running tests the linker can't find referenced symbols:
I've read about setting up Bundle Loaders and Test Host, but nobody truly explains which target they should be set on. They don't work for me and I'm wondering if such a simple, 3-file large "project" even needs tweaking around the Build Settings.
How can I simply add a Test Class that will test another class with simple assertions?
Why Is the Undefined Symbols for Architecture x86_64: Error Happening? This error is happening due to the lack of included values inside the declared statements in your code. The browser is going to render the information incorrectly and show this error, especially if you are working with Main and Similarity tools.
Unit testing is a method of testing software where individual software components are isolated and tested for correctness. Ideally, these unit tests are able to cover most if not all of the code paths, argument bounds, and failure cases of the software under test.
Murphy's Law, of course I found the answer 3 minutes after posting a question that bugged me for hours:
The class I want to test needs to be a member of the test target. After checking the appropriate "Target Membership" for the Fraction class file the errors disappeared.
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