Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Eggplant and the Cocoa Frameworks: Combining for a Rewarding Experience

When the team at Redstone Software set out to create a new software testing tool, they started with little more than an idea, limited resources, and a mandate to ship a finished product in just five months.

The idea was to deliver a tool that could automate and test any software running on any operating system. This would be accomplished by driving the user interface remotely from another computer. In essence, the software would act like a “virtual user” sitting at the keyboard of the system to be tested, watching its screen and responding with appropriate actions through the keyboard and mouse.

Five months later, Eggplant made its debut as planned. This story explains how they did it, and why they made the Mac their platform of choice. After all, Eggplant’s architecture as a two-computer system meant that it could reasonably have been delivered on any platform, and Redstone didn’t even have any Mac developers on staff at the time. But the Mac platform offered some compelling advantages.



“The decision to write Eggplant on the Mac was made partly for business reasons,” recalls Doug Simons, one of Eggplant’s principal developers. “Redstone’s strategy was to enter the software testing field by going after the Mac market first. Mac developers were in need of a GUI testing tool, and one that didn’t run on a Mac, even if it could do the job of testing Mac applications, wasn’t likely to appeal to those developers.
“The other big factor in the decision was technology,” Simons continues. “We had to produce results in a very short time with extremely limited resources in order to keep the backing of our supporters. Redstone’s founder talked to folks in the industry and learned that Apple’s Cocoa frameworks and Xcode development environment were the ideal solution for a small team on a mission.”

So Redstone Software’s management made the decision, hired Simons and “co-chef” Jonathan Gillaspie, and set them to work to cook up Eggplant on the Mac platform.

Eggplant as the Sum of its Ingredients

Like most medium-to-large software projects, Eggplant comprises a number of different areas of functionality. In addition to being able to remotely control another computer, the software needs a way to automate processes on the remote system, edit scripts, record and report test results, organize test scripts and results, and more. Plus all the usual capabilities found in most applications: changing and storing user preferences, opening and saving files, and so forth.

To solve these needs and simplify their task the Redstone developers were able to leverage a number of tools and frameworks, including those from Apple and also some from other sources.

Starting with the User In Mind

The natural starting point for many applications is the user interface. Because Interface Builder allows the interface to be put together very quickly before any code is written, it can help developers get a feel for the overall shape of the application.

“We followed a very agile process in writing Eggplant,” Simons says. “In essence, we were designing the software and writing it at the same time. Interface Builder made it really easy to create the user interface right from the start of the process which helped us to understand what we were building. It’s also really rewarding to have something concrete to look at very early in the process.”
Doug continues, “I think that paying attention to the interface from the outset also helped keep the development process focused on our end users, which ultimately helped us produce a better and more usable program. And even though Eggplant’s user interface evolved and changed during the course of development, Interface Builder facilitated these changes with minimal impact on the underlying code.”

Remote Access

The foundation of Eggplant’s architecture is its ability to control another computer. As a testing and automation tool, this gives Eggplant tremendous flexibility, enabling it to connect to and control software running on almost any operating system including Mac OS X, Windows, Solaris, HP-UX, AIX, Linux, and Windows Mobile—even mobile computing platforms such as smart cell phones are supported.

To accomplish this, Redstone chose to leverage the Macintosh platform’s excellent support for open source software—in this case using VNC (Virtual Network Computing) technology. VNC is a freely available solution for remotely controlling one computer from another. The Redstone team wrote a VNC client as an integral part of Eggplant, allowing it to access and control any computer running a VNC server.

“When we started, there was a VNC server available for Mac OS X called OSXvnc, but nobody was maintaining or improving it,” Gillaspie says. “We needed it to be rock-solid for working with Eggplant, so we took it over and became the new maintainers of that project. It’s now called Vine Server and consistently gets a 99+% activity rating on SourceForge, with thousands of free downloads every week. It’s become a way for us to give something back to the Mac community.
“Somewhere along the way, we also realized that we had created a really good VNC client within Eggplant,” Doug adds, “but we wondered how much work it would be to split that out as a separate product.
”Fortunately, Xcode’s ability to create multiple targets within a project really helped us out. By adding a Vine Viewer target to the Eggplant project, we were able to easily select which classes and resources were needed for each product. So now we can build both Vine Viewer and Eggplant from a single code base, which has proven to be a big win. For example, when we added remote screen scaling and ways to manage multiple open connections in Vine Viewer, the next release of Eggplant got those features as well.”

Image-based Interaction

Eggplant differs from most other software test automation tools by taking an image-based approach to interactions with the system under test. By visually looking for elements on the remote screen image that it receives through the VNC connection, Eggplant remains completely independent of the software it is controlling. This approach allows Eggplant to validate any application developed on any coding platform. Whether that platform is Flash, HTML, Java, .Net, C++, Objective C or any other language, if there is some part of the application that a user will be expected to interact with, Eggplant can validate the proper functioning of that application.

“The Macintosh is a natural when it comes to graphics,” Jonathan says. ”The image-handling portions of the AppKit were a huge help during Eggplant’s development. The NSImage class made it easy for us to capture images from the remote screen and store them on disk as part of an Eggplant test suite.”

Enhancements in Eggplant version 4 have further leveraged the ability of the NSImage class to open images in a wide variety of formats to enable users to import images into a suite from many external sources such as importing the source images for a website to facilitate testing of a web-based application.

Script Editing with Style

With Eggplant’s image-based approach to interaction with the remote system, it is able to automate complete processes spanning multiple applications or even multiple operating systems. The steps to automate are all recorded in the form of scripts, which the user can edit and organize however they choose.

“Thanks to the tremendous code base present in the Cocoa frameworks, the fundamental capabilities of script editing and saving practically wrote themselves,” Doug says. “The NSTextView class instantly gave us powerful text editing capabilities, including unlimited undo and redo. Using the NSDocument architecture provided additional functionality to simplify saving and managing of script files.”

A Scripting Language for Every Eggplant User

One of the key design goals for Eggplant was to create a tool that was not only highly functional, but that would also be extremely easy to use. For complex testing and automation a powerful and capable scripting language was a must, but also one that would be easy for a tester with little or no automation experience to learn and use.

To satisfy this need while appealing to users with diverse backgrounds on multiple platforms, Redstone chose SenseTalk™, an exceptionally readable and English-like language from Thoughtful Software. SenseTalk borrows much of its friendliness and intuitive syntax from HyperTalk (familiar to veterans of Apple’s HyperCard), while adding modern enhancements such as direct file and URL access, objects, lists and other data structures, plus more advanced features like socket and process communications.

In addition to being easy to use, though, Redstone also needed a language that could be easily extended with Eggplant-specific functionality. With Cocoa’s built-in support for bundles and frameworks, and the inherent dynamism of Objective C, integrating SenseTalk into Eggplant was a snap.

“With the SenseTalk framework in hand, it took less than a day to incorporate it into the Eggplant project and start writing scripts,” says Gillaspie. “Thanks to Objective C’s dynamic messaging, we can add new SenseTalk commands and functions by just adding a new method. By subclassing a central controller class we could customize the way SenseTalk works within Eggplant, and were even able to write a powerful script debugger.”

A Movie Is Worth a Thousand Pictures

When software tests fail, knowing that there is a problem is helpful, but to be able to solve the problem it is imperative for testers to communicate clearly to the developers the exact circumstances under which the failure occurred. To this end, Eggplant logs every action taken on the system under test leading up to the failure, and automatically captures a full image of the screen at the time of failure. In addition, it can optionally record a QuickTime movie of any portion of the process.

“We never would have tried to add movie recording on our own,” says Doug. “But with the QTKit in Cocoa providing the movie-making muscle, we were able to include it with minimal effort, and provide our customers with one more great feature that sets us apart from the competition.”

Networking Made Easy

Apple’s Bonjour technology for advertising and discovery of network services provided yet another win for the Redstone developers. With a strong focus on providing an excellent user experience to their customers, the need for inexperienced users to be able to correctly establish a network connection to another machine was a real concern. Having to supply the network identity of a system under test and ensure the proper network connections from the outset in order to begin testing threatened to be a stumbling block for many users.

“The good news is, by adding just a few lines of Bonjour code to the Vine Server, it can now advertise itself on the network as a VNC server,” says Jonathan. “With the corresponding discovery code included in Eggplant, it instantly senses the presence of any Bonjour-enabled servers on the network, which are displayed in a dynamically updated list. Users can connect to a server by just double-clicking a name in the list, and then devote their attention to the testing or automation task that they really care about.”

Only On a Mac

According to the folks at Redstone, Eggplant wouldn’t be the tool that it is if it were developed on another platform. The presence of advanced graphic rendering, superior coding tools, and a wealth of frameworks on top of a strong UNIX foundation all contribute to a development platform that has allowed Redstone Software to build the industry leading cross-platform Automated Software Quality testing tool.

“Developing Eggplant on the Mac has been an extremely rewarding experience,” says Doug Simons. “Many of our customers buy Eggplant to test software or automate processes running on Windows, Linux, or other systems. It often happens that these organizations don’t even own a Mac, but turn to Eggplant because it is uniquely capable of driving software that other systems simply can’t automate.

So even if a company does not have a Mac in-house initially, they can find the benefits of cross platform testing, plus a great user experience from Eggplant, means that getting their first Mac to run the software is well worth the investment.

“As developers we love working on the Mac,” Gillaspie adds. “Using Cocoa has allowed us to continually innovate and improve Eggplant, adding features that enhance the experience for our users. We can get things done faster and with better quality than we could achieve on any other platform.”

A Special Offer for ADC Members

This article may inspire you to consider cooking up some excellent products with the help of Eggplant. Redstone is offering a special discount of 15% to any ADC member who buys Eggplant Functional Tester or Eggplant Starter Edition from Redstone’s online store on or before 30-June-2008. To claim your discount, simply enter ADC-PROMO in the Promotion Code field before you check out. See the Redstone online store for details.

For more information about Eggplant, see the Redstone Software website.