• 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: Matt Neuburg <email@hidden>
  • Date: Wed, 06 Dec 2006 12:23:40 -0800
  • Thread-topic: unit testing with SenTestingKit, please hold my hand

On Tue, 5 Dec 2006 14:11:50 -0800, Andrew Pontious <email@hidden>
said:
>
>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.

Thanks, Andrew, but I don't believe that that's the case. First, the Bundle
Loader stuff is in a section about "Making Your Target Dependent on the Main
Executable," which is exactly what I'm not doing (so I skipped it). Plus, as
I said before, I first did this tutorial:

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

...which adds a non-dependent unit test bundle to the existing
CurrencyConverter example, and there is no Bundle Loader or Test Host step.
Yet it works just fine. Experientia docet; clearly it *should* just work.

In the end I never figured out what the trouble was. I had to throw the
project away. I started over from scratch and everything was fine.

I should probably file a bug against the other doc:

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

...since, as I said, it omits a major step (linking the SenTestingKit into
the project / target). m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



 _______________________________________________
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

  • Follow-Ups:
    • Re: unit testing with SenTestingKit, please hold my hand
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: Builds cause iTunes to stutter
  • Next by Date: Re: unit testing with SenTestingKit, please hold my hand
  • Previous by thread: Re: unit testing with SenTestingKit, please hold my hand
  • Next by thread: Re: unit testing with SenTestingKit, please hold my hand
  • Index(es):
    • Date
    • Thread