Note that there are some explanatory texts on larger screens.

plurals
  1. POOCUnit Tests giving errors in classes not being tested
    primarykey
    data
    text
    <p>I have written an OCUnit test, which ran fine in Xcode 3.2, and now I'm having problems with it in Xcode 4. It tests a single static function <code>X</code> in class <code>A</code>, which doesn't call any classes or functions (outside of library functions). The only other code that should need to be called is the static constructor, which initializes two static variables, but again, those are hardcode values (arrays) that don't call any other classes, or functions of class <code>A</code>.</p> <p>And yet, I had to include the .m, .mm, and .c files for all classes that it imports, and that they import, and so on, to solve the <strong>_OBJC_CLASS_$_ClassB", referenced from:</strong> errors. I don't recall having to do any of that in Xcode 3, but fine, no problem, I got it to compile. Now, I'm getting errors originating from class <code>B</code>'s <code>+[B initialize]</code>.</p> <p>Why is the static constructor getting called on a class that is not referenced in any way? How can I fix this, ideally without changing my classes to acommodate the testing?</p> <p><strong>Update</strong></p> <p>To further figure out what's going on, I commented out all my test cases and the <code>#import "A.h"</code> to see what would happen. I added a single simple unit test:</p> <pre><code>- (void) testSomething { STAssertTrue(NO, @"did it work?"); } </code></pre> <p><em>Still</em>, my <code>+[B initialize]</code> gets called and fails. It seems that OCUnit is crawling through all of my classes, and their <code>+initialize</code> methods are getting called in the process. This makes no sense to me - how can I disable this behavior?</p> <p>Here is the stack trace before my own code gets called, in case it helps:</p> <pre><code>#7 _class_initialize () #8 prepareForMethodLookup () #9 lookUpMethod () #10 objc_msgSend () #11 +[NSObject(SenTestRuntimeUtilities) senIsASuperclassOfClass:] () #12 +[NSObject(SenTestRuntimeUtilities) senAllSubclasses] () #13 +[SenTestSuite updateCache] () #14 +[SenTestSuite suiteForBundleCache] () #15 +[SenTestSuite testSuiteForBundlePath:] () #16 +[SenTestProbe specifiedTestSuite] () #17 +[SenTestProbe runTests:] () #18 &lt;????&gt; () #19 &lt;????&gt; () #20 &lt;????&gt; () #21 &lt;????&gt; () </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload