Unit Testing Frameworks

  • Hello all.

    I am having a problem with setting up unit testing for frameworks.
    I've read the documentation that is provided in the Apple doc set <> and found Chris Hanson's updates to that documentation at <<A href="http://chanson.livejournal.com/119303.html">http://chanson.livejournal.com/119303.html>. I've set up the framework to include a new target with the Unit
    Test Bundle and added my tests to it. I've also set up the dependency
    so that the tests should be run when the framework gets built (at
    least that's what I understand should happen), and I've set the target
    membership for my framework so that my framework gets linked into the
    tests.

    The framework builds correctly -- no warnings or errors, but the test
    cases do not get built automatically. I then switch my active target
    to my test bundle (creatively named Tests), and do a build and get the
    following error dump (note I've highlighted the line I believe to be
    the major error):

    /bin/sh -c /Users/cooper/src/Sections/build/Sections.build/Debug/
    Tests.build/Script-1E7E14D00EEC6FD2006D87B7.sh
    /Developer/Tools/RunPlatformUnitTests.include:358: note: Started tests
    for architectures 'i386'
    /Developer/Tools/RunPlatformUnitTests.include:365: note: Running tests
    for architecture 'i386' (GC OFF)
    objc[42098]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
    objc[42098]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
    2008-12-07 14:15:35.042 otest[42098:80f] The executable for the test
    bundle at /Users/cooper/src/Sections/build/Debug/Tests.octest could
    not be found.
    2008-12-07 14:15:35.044 otest[42098:80f] Usage: otest [-SenTest Self |
    All | None | <TestCaseClassName/testMethodName>] <path of unit to be
    tested>
    2008-12-07 14:15:35.046 otest[42098:80f] *** -[NSCFDictionary
    setObject:forKey:]: attempt to insert nil value (key:
    _NSTaskExecutablePath)
    /Developer/Tools/RunPlatformUnitTests.include:384: error: Failed tests
    for architecture 'i386' (GC OFF)
    /Developer/Tools/RunPlatformUnitTests.include:393: note: Completed
    tests for architectures 'i386'

    I'm not sure why I'm getting this error, and what I should do to
    correct it so the tests run correctly.

      If anyone could shed some light on this for me I'd be really
    appreciative.

    Thanks very much.

    Thaddeus O. Cooper
    (<tcooper...>)
  • Woops -- the highlighting didn't come through. Here is the line from
    below:

    > 2008-12-07 14:15:35.042 otest[42098:80f] The executable for the test
    > bundle at /Users/cooper/src/Sections/build/Debug/Tests.octest could
    > not be found.

    Thaddeus O. Cooper
    (<tcooper...>)

    Begin forwarded message:

    > From: Thaddeus Cooper <tcooper...>
    > Date: December 7, 2008 2:25:37 PM PST
    > To: Cocoa-Dev Mail <cocoa-dev...>
    > Subject: Unit Testing Frameworks
    >
    > Hello all.
    >
    > I am having a problem with setting up unit testing for frameworks.
    > I've read the documentation that is provided in the Apple doc set <http://developer.apple.com/documentation/DeveloperTools/Conceptual/UnitTest
    ing/UnitTesting.pdf
    > > and found Chris Hanson's updates to that documentation at <http://chanson.livejournal.com/119303.html> >. I've set up the framework to include a new target with the Unit
    > Test Bundle and added my tests to it. I've also set up the
    > dependency so that the tests should be run when the framework gets
    > built (at least that's what I understand should happen), and I've
    > set the target membership for my framework so that my framework gets
    > linked into the tests.
    >
    > The framework builds correctly -- no warnings or errors, but the
    > test cases do not get built automatically. I then switch my active
    > target to my test bundle (creatively named Tests), and do a build
    > and get the following error dump (note I've highlighted the line I
    > believe to be the major error):
    >
    > /bin/sh -c /Users/cooper/src/Sections/build/Sections.build/Debug/
    > Tests.build/Script-1E7E14D00EEC6FD2006D87B7.sh
    > /Developer/Tools/RunPlatformUnitTests.include:358: note: Started
    > tests for architectures 'i386'
    > /Developer/Tools/RunPlatformUnitTests.include:365: note: Running
    > tests for architecture 'i386' (GC OFF)
    > objc[42098]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
    > objc[42098]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
    > 2008-12-07 14:15:35.042 otest[42098:80f] The executable for the test
    > bundle at /Users/cooper/src/Sections/build/Debug/Tests.octest could
    > not be found.
    > 2008-12-07 14:15:35.044 otest[42098:80f] Usage: otest [-SenTest Self
    > | All | None | <TestCaseClassName/testMethodName>] <path of unit to
    > be tested>
    > 2008-12-07 14:15:35.046 otest[42098:80f] *** -[NSCFDictionary
    > setObject:forKey:]: attempt to insert nil value (key:
    > _NSTaskExecutablePath)
    > /Developer/Tools/RunPlatformUnitTests.include:384: error: Failed
    > tests for architecture 'i386' (GC OFF)
    > /Developer/Tools/RunPlatformUnitTests.include:393: note: Completed
    > tests for architectures 'i386'
    >
    > I'm not sure why I'm getting this error, and what I should do to
    > correct it so the tests run correctly.
    >
    > If anyone could shed some light on this for me I'd be really
    > appreciative.
    >
    > Thanks very much.
    >
    > Thaddeus O. Cooper
    > (<tcooper...>)
  • On 08/12/2008, at 8:25 AM, Thaddeus Cooper wrote:
    > The framework builds correctly -- no warnings or errors, but the
    > test cases do not get built automatically. I then switch my active
    > target to my test bundle (creatively named Tests), and do a build
    > and get the following error dump (note I've highlighted the line I
    > believe to be the major error):

    > 2008-12-07 14:15:35.042 otest[42098:80f] The executable for the test
    > bundle at /Users/cooper/src/Sections/build/Debug/Tests.octest could
    > not be found.

    It looks like you have not configured the BUNDLE_LOADER configuration
    directive in your Tests target's settings to point to your executable.

    You need to make sure that the bundle loader is set to $
    {BUILT_PRODUCTS_DIR}/YourAppName.app/Contents/MacOS/YourAppName for
    the test target to be able to launch your app and run the tests.

    --
    Rob Keniger
  • Thanks. I finally got over the hump -- it turned out to be that the
    test cases were not in the right target.

    Now that that's fixed I'm trying to get debugging of the framework
    working and I keep getting a launch path not accessible error. I added
    the executable target and set the arguments to

    -SenTest All
    Section Tests.octest

    and my environment variables to:

    DYLD_LIBRARY_PATH $(BUILT_PRODUCTS_DIR)
    DYLD_FRAMEWORK_PATH $(BUILT_PRODUCTS_DIR)
    OBJC_DISABLE_GC YES

    otest runs but gives the following error:

    objc[46258]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
    Running…
    objc[46258]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
    2008-12-07 20:03:03.415 otest[46258:813] Usage: otest [-SenTest Self |
    All | None | <TestCaseClassName/testMethodName>] <path of unit to be
    tested>
    2008-12-07 20:03:03.421 otest[46258:813] launch path not accessible

    I've tried -SenTest All, -SenTest None, and a variety of things for
    Section Tests.octest including prefixing it with ${BUILT_PRODUCTS_DIR}
    and without, and even removing it altogether. All with the same
    result. I'm pretty sure that the problem is a dumb one but I can't see
    it.

    Once again -- thanks to all who have responded and if anyone has any
    thoughts I'd be really appreciative.

    Thanks very much.

    Thaddeus O. Cooper
    (<tcooper...>)

    On Dec 7, 2008, at 4:48 PM, Rob Keniger wrote:

    >
    > On 08/12/2008, at 8:25 AM, Thaddeus Cooper wrote:
    >> The framework builds correctly -- no warnings or errors, but the
    >> test cases do not get built automatically. I then switch my active
    >> target to my test bundle (creatively named Tests), and do a build
    >> and get the following error dump (note I've highlighted the line I
    >> believe to be the major error):
    >
    >
    >> 2008-12-07 14:15:35.042 otest[42098:80f] The executable for the
    >> test bundle at /Users/cooper/src/Sections/build/Debug/Tests.octest
    >> could not be found.
    >
    >
    > It looks like you have not configured the BUNDLE_LOADER
    > configuration directive in your Tests target's settings to point to
    > your executable.
    >
    > You need to make sure that the bundle loader is set to $
    > {BUILT_PRODUCTS_DIR}/YourAppName.app/Contents/MacOS/YourAppName for
    > the test target to be able to launch your app and run the tests.
    >
    > --
    > Rob Keniger
  • On Dec 7, 2008, at 8:11 PM, Thaddeus Cooper wrote:

    > Now that that's fixed I'm trying to get debugging of the framework
    > working and I keep getting a launch path not accessible error. I
    > added the executable target and set the arguments to
    >
    > -SenTest All
    > Section Tests.octest

    This will be interpreted as 4 arguments, not the 3 that it needs to
    be; as a convenience, Xcode will let you put multiple arguments
    separated by spaces in a single entry in the Arguments table.

    Try putting quotes around the name of your test bundle, e.g. "Section
    Tests.octest", so it's interpreted as a single argument.

      -- Chris
previous month december 2008 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today