1

I successfully added the Kiwi testing framework to my existing project using Cocoapods.

target :KiwiUnitTest do
    pod 'Kiwi'
end

I can create a very basic test and have it pass:

describe(@"A simple test", ^{
    context(@"when adding 1 + 1", ^{
        it(@"should equal 2", ^{
            [[theValue(1+1) should] equal:theValue(2)];
        });
    });
});

However, when I attempt to test one of my models, things fall apart.

I include my model's .h file in my spec:

#import "MyModel.h"

And then a whole slew of errors come in when I run my tests.

A few things that I can't figure out:

  • As mentioned, I added my testing target to an existing project. How do I share my model class with my new testing target? By simply selecting the .m file in Build Phases/Compile Sources?
  • If my model uses other models/helper classes/categories, do I need to share those with the testing target too? And do I need to import all of those files into my spec file as well?
  • My model relies on AFNetworking, which I also have installed as a Cocoapod. How can I use that library in my testing target? I've tried simply importing AFNetworking.h but that obviously fails.

Thanks!

Pooria Azimi
  • 8,585
  • 5
  • 30
  • 41
djibouti33
  • 12,102
  • 9
  • 83
  • 116
  • I really wish I could get this to work, too. I've followed the directions on the Kiwi wiki for setting it up, and it works — until I introduce my own code / imports. Ugh. – Ben Kreeger Jan 18 '13 at 16:18

1 Answers1

0
  • I've read other advices, but we ended up including all non-test .m files in the test target in 'Compile Sources', in addition to the .m files of the test code
  • After adding the test target, you probably need to run pod install again. It should set up the dependencies for you testing target and the normal target.
Pieter Kuijpers
  • 7,247
  • 5
  • 28
  • 36
  • Well, that kind of worked. I added all non-viewController files to "Compile Sources", but running pod install didn't seem to have any effect. I was still getting tons of errors, so I basically duplicated the "Link Binary with Libraries" section in my Test Target. That got rid of all the errors I was seeing, but now I get `Error loading ...KiwiUnitTest: dlopen(...) Symbol not found: _objc_setProperty_nonatomic...IDEBundleInjection.c: Error loading bundle (...KiwiUnitTest.octest). Good thing I'm on a branch because this is all a mess now. – djibouti33 Oct 03 '12 at 01:34