dimanche 26 avril 2015

Objective C Unit Test Setup

I have been learning Objective C and Xcode for a few months now, and I am trying to setup some unit tests.

All of my projects are OS X "Command Line Tool" Applications. I use main.m to write code to test the methods and classes I've developed. That works fine. I'm trying to migrate to test targets and unit testing.

I am using "Testing with Xcode" as a guide, but I'm having some issues:

  1. When I create a "Test Target", the "Target To Be Tested" field defaults to "None", and can't be changed. Is that okay?
  2. I am able to run the default tests. They pass. But when I create a new test that references a class method that I've written, I get a link error for each class method instance. (not a compile error)

My "ExampleTest.m" test target has an '#import "MyApp.h"', Is there any other setup I need to do?

The "Testing with Xcode" doc shows a setup test method that invokes the ViewController for the app being tested. I don't have a ViewController for my command line app, and I'm only trying to create unit tests, so I'm not sure how to modify that example...

Bonus Question: I have several classes that I add methods to, and want to reuse. How do I keep the unit tests with the source code for reuse? The Test Navigator hierarchy seems to be app-centric. How to others keep their classes and unit tests for those classes in sync?

Aucun commentaire:

Enregistrer un commentaire