unit testing - OCUnit for iPhone App - Set all .m files as part of UnitTest Target -
hy everybody,
i have 2 targets: myapp , unittests
myapp contains 2 classes: classa , classb. classa has method "getsomenumber" uses classb method.
unittest "unit test bundle" , in "groups & files" section have folder named "unittests" create "myapptest" class.
myapptest class has following method:
-(void)testsomething { classa *ca = [[classa alloc] init]; int x = [ca getsomenumber]; [ca release]; stassertequals(1, x, @"the number not equal 1"); }
i imported "classa.h" , need set "classa.m" part of "unittest" target. when build have error
**"_objc_class_$_classb", referenced from:**
so need add "classb.m" "unittest" taget , works.
what happens if classa uses classc uses thousands of classes? have problem , need include thousand of class "unittest" target.
i think sould better solution or configuration include whole myapp project unittest target.
thank all! regards.
if have dependencies on thousands of classes, suggest organize classes libraries can reuse. way, can link targets (for testing or otherwise) against single library, rather including lots of individual code files.
if you're targeting ios device you'll need create static libraries, since dynamic linking custom libraries not possible on devices.
Comments
Post a Comment