Re: ZeroLink and dynamic discovered Classes
Re: ZeroLink and dynamic discovered Classes
- Subject: Re: ZeroLink and dynamic discovered Classes
- From: Marco Scheurer <email@hidden>
- Date: Thu, 27 Nov 2003 12:31:46 +0100
On Wednesday, November 26, 2003, at 04:26 PM, I wrote:
On Sunday, November 23, 2003, at 11:03 PM, Martin Hdcker wrote:
Hi there,
to get to know the inside of the objc-runtime I am coding a simple
unit-testing framework for myself. But, well, I got myself totally
stuck on this problem:
I'd like to do automatic test-case discovery and currently get a list
of all classes from the runtime before I filter out those that are no
testcases.
BUT if zero-link is enabled I never get my testclasses listed. Well
that is to be expected as those classes are not explicitely
specified/instantiated anywhere else in the source.
OCUnit, which already does all this (unit testing and automatic
discovery of test case classes, http://www.sente.ch/software/ocunit)
has the same problem. We haven't found a worthy workaround yet.
Here is a workaround.
First note that with OCUnit this problem of not discovering TestCase
subclasses with ZeroLink on happens only for tests that are embedded in
applications. This workaround is not needed to run tests in frameworks
for instance.
The workaround is not very elegant but simple, and could easily be
added to a file template: add a category in the file containing the
implementation of your test subclass.
#import "MyTestCase.h"
@implementation MyTestCase (ForceDiscoveryUnderZeroLink) @end
@implementation MyTestCase
- (void) test...
@end
If you have not defined no-load-categories-before-main this will force
the linking of the .o file at runtime, thus ensuring that your class is
found.
For more information, see for instance
http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/
ZeroLinkReleaseNotes.html
marco
Marco Scheurer
Sen:te, Lausanne, Switzerland
http://www.sente.ch
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.