• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CPlusTest in Xcode 2.3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CPlusTest in Xcode 2.3


  • Subject: Re: CPlusTest in Xcode 2.3
  • From: Aaron Montgomery <email@hidden>
  • Date: Fri, 14 Jul 2006 12:50:43 -0700


On Jul 14, 2006, at 11:59 AM, John Richetta wrote:

1. Has this problem Aaron asked about been resolved or investigated? I have the exact same problem(Xc 2.3, OS X 10.4.7): simple TestCases, without any setup and teardown (yet), and which consistently crash at program exit, whenever there is more than one test case.

Not by Apple. It has problem id 4560190 and is still listed as open. However, adding the "Other C Flag" of -fno-use-cxa-atexit in the Unit Tests target will prevent crashing. The problem appears to be how termination routines are being executed when libraries are unloaded. CPlusTest is not the only situation where this is problematic so I'm guessing it will be fixed, I just don't know when.


2. Has anyone beside me tried to use CPlusTest in a stand-alone test jig application? I find the motivations for the test bundle machinery indirectly discussed in the Unit Testing Guide to be rather unclear. I don't understand:

I'm sure someone with more knowledge than I have can give you better answers to these. But I'll make some guesses.


a. why it says the test target doesn't need the source code under test to be added to it (the grey box at the top of page 12 baffles me); how does the "injected" bundle "[access] any source code required for the tests"??

Your application should be exporting its symbols. So the injected bundle uses your application the same way your application uses prebuilt libraries. It knows that it needs to call function foo() and knows where foo() is located inside your application's compiled code.


b. why I'd want to "inject" a bundle into an application (and specifically, exactly what that means) to test it - I normally do all unit testing in stand-alone applications. There are cases where testing within a complete application is desirable, but they are much less common for me. I'm not sure why I'd want any significant machinery to achieve this - why not simply conditionally compile my tests into a (non-final) target?

Completely naive response here. I'm guessing that injecting the bundle just means that you are adding some code to be executed in the context of the running application. In some sense, your application's code is being injected into Mac OS X's system code every time it is run.


I guess you could achieve the same result with conditional compilation. I like the fact that my testing code is separate from my production code (not intermingled). Also by not mingling the code, when I run gcov (or lcov) while doing unit testing, I just get coverage results from the application code and not both from the application code and the unit testing code. In larger systems, it will allow application programmers and quality controllers to each have their own codebases that don't overlap (although they certainly need to be in agreement about what the application functions are supposed to be doing).

P.S. - One more thing: is source for the Apple version of CPlusTest available somewhere that I missed? I haven't figured out a good way to search Apple's open source, but I didn't see it browsing around the likely places and (unsurprisingly) it doesn't appear to be part of the developer tool distribution.

I've done a fair amount of digging and cannot find it.

Hope that helps, I put together a short MacTech article on this (hopefully it will be published), but I can't say that it will help you with answers to Question 2. It is more focused on how to set up the project targets rather than why you would want to do unit testing in this particular fashion.

Aaron
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: CPlusTest in Xcode 2.3
      • From: John Richetta <email@hidden>
References: 
 >Re: CPlusTest in Xcode 2.3 (From: John Richetta <email@hidden>)

  • Prev by Date: Re: CPlusTest in Xcode 2.3
  • Next by Date: Header Search Paths / Multiple Header Files with the same name
  • Previous by thread: Re: CPlusTest in Xcode 2.3
  • Next by thread: Re: CPlusTest in Xcode 2.3
  • Index(es):
    • Date
    • Thread