discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C Unit Testing under linux


From: Marcel Weiher
Subject: Re: Objective-C Unit Testing under linux
Date: Thu, 20 Mar 2003 13:45:17 +0100


On Wednesday, March 19, 2003, at 07:58  Uhr, Travis Griggs wrote:

I'm frustrated with my inability to lay my hands on an easy to install/understand/use unit tester for objective-c, running under linux. I'm using the GNUstep base/makefiles stuff as a core library under Linux. There are (2?) objc-unit testing frameworks, but they seem to be very apple/osx/graphic centric. I just want something simple. Command line based. I toyed with porting ObjcUnit, but it had _lots_ of classes, was based off of JUnit. Being a veteran Smalltalker, but newbie objc'er, I'd like something a little more Smalltalk centric. Am I just going to have to write my own?

Try MPWTest. It is the simplest unit testing framework I could think of, and I get pretty extreme when it comes to simplicity. You can get it from

        http://www.metaobject.com/downloads/Objective-C/

(the tgz is 6.3 KBytes...;-)

If you want to see how it is used, download the MPWFoundation from the same place. In a nutshell, each class that wants to be tested defines a +testSelectors method which returns an NSArray of NSStrings which are the selectors to send. In the default case, these selectors are sent to the class and the tester checks for exceptions. No exception means the test passed.

The implementation allows some flexibility in that the class can choose to handle the named tests differently (which I use to run various Postscript test files through my Postscript interpreter), or you can return a different object to actually run the tests (an initialized instance, for example). But that is fairly rare.

Per default, the entitites tested are frameworks (any loadable bundle will do), which are assumed to live in (or at least have ghosts in) /Library/Frameworks/. You simply run testlogger on the command line, providing as arguments the names of all the frameworks you want to test.

Attachment: testlogger_main.m
Description: Binary data



Thinking...well, with GNUstep, I think I didn't actually have the time/nerve to try and get the unit-testing framework running, because it uses some runtime trickery to figure out which classes to test. So instead, I just wrote a little program that ran the tests "per pedes". So I guess my testing framework wasn't really minimal, because the following is a "sufficient" (if not entirely elegant) replacement for it.

Attachment: testall.m
Description: Binary data




--
Marcel Weiher                           Metaobject Software Technologies
marcel@metaobject.com           www.metaobject.com
Metaprogramming for the Graphic Arts.   HOM, IDEAs, MetaAd etc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]