I am keen to write a library project with tests, even if I then include the code in other projects (as opposed to linking to the lib.) for inclusion on ios projects.
It seems checking the 'Include unit tests' isn't enough for xcode 4 to properly initialise a project with tests, and after looking through the Apple documentation I can't find anything relevant.
Does anybody know of any resources or tutorials for getting this working?
Even with the default Cocoa Touch Static Library project, upon choosing "Test" from the "Product" menu, it fails (when linking) with this error (the project is called test1
):
library not found for -ltest1
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
Any help would be much appreciated.
Enable Unit Tests in Xcode ProjectWhile creating a new Project, click the checkbox “Include Unit Tests”, “Include UI Tests”. Once created, you can able to see a folder in the project called “ProjectNameTests” and the XCode already creates a default test case class with a template generated to start working with.
Test-driven development (TDD) is a software development process relying on software requirements being converted to test cases before software is fully developed, and tracking all software development by repeatedly testing the software against all test cases.
Red, Green and Refactor is the three phase of Test Driven Development and this the sequence that get followed while writing code. When followed, this order of steps helps ensure that you have tests for the code you are writing and you are writing only the code that you have to test for.
OK I finally got this working.
The trick was to create the library without checking the 'Include unit tests' option in XCode 4. Then I created a new target myself.
(in xcode 4)
I hope this helps.
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