Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 5.6

FEATURE

PostMortem: RBUnit

Unit Testing for REALbasic

Issue: 5.6 (September/October 2007)
Author: Paul Lefebvre
Author Bio: Paul Lefebvre is the President of LogicalVue Software, Inc. and founder of RBDevZone, the free community for professional REALbasic developers.
Article Description: No description available.
Article Length (in bytes): 8,437
Starting Page Number: 11
Article Number: 5607
Related Web Link(s):

http://www.logicalvue.com/

Excerpt of article text...

It all began in early 2004. I was working with Visual Studio 2003 and learning about unit testing. And I liked it. A lot. In the .NET world there are lots of unit testing frameworks to choose from. I used both nUnit and csUnit. Both of these unit test frameworks included a "test runner" UI that showed test results visually. I preferred the csUnit test runner (see Figure 1).

During this same time I was also spending a lot of time with REALbasic as I was developing SQLVue 3.0. I thought it would be useful to have a unit testing framework for REALbasic, but after searching for a while was unable to find one. So I decided to create one. I based RBUnit on csUnit and its test runner.

Developing RBUnit 1.0

It turns out that creating a unit testing framework in REALbasic is not as easy as it is in some other languages because REALbasic does not have reflection (see sidebar). Without reflection, it is not possible for the unit testing framework to determine what the test methods are. So for RBUnit 1.0, I used a rather inelegant method of having the user call their test method manually with a parameter to specify the method name so that it could be displayed in the UI. It was a bit awkward as you can see here:

TestAssertNotNil(AddTest("TestAssertNotNil"))

I thought the UI was pretty nice, though (see Figure 2). It showed the names of the test methods and made it really easy to visually see which ones passed and which ones failed. In addition, RBUnit also had the ability to track the amount of time spent in the test methods (see Figure 3).

...End of Excerpt. Please purchase the magazine to read the full article.