Help with Logic & Application Unit Testing...

Discussion in 'iOS Programming' started by midntdj, Apr 6, 2010.

  1. midntdj macrumors newbie

    Joined:
    Sep 23, 2009
    #1
    I'm attempting to create some Unit Tests for Logic & Application. I went through the sample program in the Apple Docs and even down loaded the iPhoneUnitTesting project.

    What I can't see to figure out or find in any the documentation or samples, is how to include your own classes / methods into the Unit test file and get it to link correctly.

    I have a class that sets up data for a picker, and I want to just verify that the data is populated correctly and it matches the code that is expected.

    But when I include the .h file in one of my Unit Test files, I get a linking error during the build. "_OBJC_CLASS_$_MyClass", referenced from: _objc_classrefs_DATA@0 in MyClassTest.o Symbol(s) not found.

    I'm sure it's just something in the Unit Test setup that I'm missing.

    I created/copied my target app and renamed it "MyAppTesting".
    I added my TestBundle to MyAppTesting as a dependency.
    My TestBundle contains the compiled tests sources
    And I verified that the target: MyAppTesting contains the Include file of the Class I'm attempting to use in it's Compile Sources.

    Any help would be grateful.
     
  2. Inriky macrumors newbie

    Joined:
    Aug 3, 2010
    #2
    Is there any solution?

    I have same problem.

    In "Xcode Unit Testing Guide" I found instruction to set "Bundle Loader" and "Test Host" of Test Bundle target (http://developer.apple.com/mac/libr....html#//apple_ref/doc/uid/TP40002171-CJBIHGEI)

    But value is wrong, and to resolve this problem must set "$(CONFIGURATION_BUILD_DIR)/MyApp.app/MyApp".

    But linker error is not resolved.

    Who know how correctly setting up Unit Test.
     
  3. seepel macrumors 6502

    seepel

    Joined:
    Dec 22, 2009
    #3
    If you click get info on your class source file and check the targets, you're sure it is set to link to all relevant targets?
     
  4. Luke Redpath macrumors 6502a

    Joined:
    Nov 9, 2007
    Location:
    Colchester, UK
    #4
    Unfortunately whilst integrated unit tests using the bundle loader setting is the best way of running unit tests because it doesn't require you to add your application code to your test target, its not currently supported with iPhone applications (although it does work when developing static libraries, including CocoaToucn static libraries).

    The solution is to make sure any classes you are trying to test are added to both your application and unit testing target.
     

Share This Page