• 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: unit testing with SenTestingKit, please hold my hand
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unit testing with SenTestingKit, please hold my hand


  • Subject: Re: unit testing with SenTestingKit, please hold my hand
  • From: Andrew Pontious <email@hidden>
  • Date: Tue, 5 Dec 2006 14:11:50 -0800


On Dec 5, 2006, at 10:53 AM, Matt Neuburg wrote:

Could someone please give me instructions for writing a Cocoa/ObjC unit test
that actually work?


First I followed the instructions in this document:

<http://developer.apple.com/tools/unittest.html>

I added a unit test to the existing TemperatureConverter example, and
everything went great. Okay, fine. On to my own project. I followed the
instructions in this document:


<http://developer.apple.com/documentation/DeveloperTools/Conceptual/UnitTest
ing/Articles/CreatingTests.html>

But nothing worked out correctly.

(1) I created a build target of type Unit Test Bundle.

(2) I decided I wanted it to be independent, so I skipped all the dependency
stuff.


(3) I created a subclass of SenTestCase and gave it a void instance method
called testWholeThing.


(3a) I linked in the SenTestingKit framework (as far as I can tell, Apple's
document completely omits this step!).


(4) I tried to build but things kind of blew up. None of my Cocoa symbols
were being recognized in the ld phase. I added the Cocoa framework to the
unit test target, but I don't understand why I have to; I didn't need to do
this in the TemperatureConverter example.


(5) I added the class I want to test to the testing target.

I build the testing target but nothing happens. The test case class compiles
okay, the Run Script phase is being executed (as I determined by adding an
"echo" to it), but testWholeThing does not run (as confirmed by adding
NSBeep(), logging, breakpoint, anything I could think of - I even put in an
STFail call). The build output is:


Suite All started
Suite All finished
Ran 0 tests, 0 failed.

How do I get my tests to be seen and run?

The thing I *really* don't understand is that I've got two projects, mine
and the TemperatureConverter example, and the former is not working but the
latter is. Yet they appear, as projects, to be structured exactly the same
way (except that, as I mentioned before, I had to add the Cocoa framework to
the test case target in my project, but not in TemperatureConverter).


thx -

When you skipped the dependency stuff, did you also skip the setting the Bundle Loader and Test Host build settings? If you're attempting to add tests to an application (by injecting the bundle into the application), you need to do that part. Search on Bundle Loader in the "Add Unit Tests to Your Project" document you mentioned above.

-- Andrew
_______________________________________________
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


References: 
 >unit testing with SenTestingKit, please hold my hand (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: C++ inlining and function definitions in headers (was Re: XCode Falls Short - for now)
  • Next by Date: Re: compiling for ppc only... no i386
  • Previous by thread: unit testing with SenTestingKit, please hold my hand
  • Next by thread: Re: unit testing with SenTestingKit, please hold my hand
  • Index(es):
    • Date
    • Thread