PalmCUnit: A Unit Testing framework for testing Palm apps written in C

While working on PalmFrotz, I decided to apply the XP principles that I was using at work. (In this context, XP stands for eXtreme Programming — not the Microsoft Operating System.) I found something called PalmUnit, which is a C++ test runner for Palm. Since I was not writing PalmFrotz in C++, I didn’t use that runner.

However, I also found source code (at the same website) for a test runner for Palm that was a port of CUnit. I quickly found that it was lacking some basics of a test runner, so I updated it (fixing some memory leaks and such along the way). I emailed the original author, but I never heard back from him. I assume that his version of the code is pretty much abandoned.

So I’m going to place the source code here for anyone else to use.

Unfortunately, I haven’t played with Palm programming in some years now. What is here may only be of historical interest — I don’t know what’s “state of the art” for unit testing Palm apps now-a-days. I don’t even have the Palm tool chain installed on any of my machines anymore. So take this code for what it is worth. But I really liked it when I was using it… 🙂

palmcunit-showsuccess.jpg
Ahhh… The green bar. What every XP coder strives for.

palmcunit-showfails.jpg Here’s PalmCUnit showing some failures.

palmcunit-showfailure.jpg There is a detail screen available for each test that fails.

Version History

PalmCUnit 1.4.1

At one point, Ben Combee put a nice article about using PalmCUnit on his website, http://palmos.combee.net (how cool!). In the process, he provided a couple small changes and a .MCP project file for building PalmCUnit in the CodeWarrior V9 environment. I don’t have access to CodeWarrior at this time, so I’m just passing the file on in this package.

Here’s a download link: PalmCUnit version 1.4.1

PalmCUnit 1.4

Thanks to Michael Nordstrom at the Plucker project (http://www.plkr.org) a few embarrassing bugs have been dealt with. I guess that’s to be expected when the author of the code is the only one using it for some time. Thanks Michael! Glad to know that someone else is using PalmCUnit!

PalmCUnit 1.3.2

The Main GUI pane is a little more friendly — the “Runs:” and “Failures:” entries now change dynamically as the tests are run.

PalmCUnit 1.3.1

I’ve made the last suite of tests run to be the default suite on the next launch of the application. This is very handy when combined with the “Run tests on app launch” preference.

PalmCUnit 1.3

While adding GUI form testing to my PalmFrotz project, I found that I needed a different style of ASSERT macro: one that allows me to define a section of the code for cleanup at the end of the test.

I’ve added a set of macros that end in _GOTOERR. Each of these behaves like their similarly named counterparts, except that instead of just returning to the calling code immediately upon registering the test failure, it branches to a label called ERR:. This was very important in my form unit testing, as I needed to set the tested form as the active
form in order for it to behave correctly in testing. Of course, if such a test fails, I need it to set the unit testing framework’s form back to the current active form before exiting the test.

If you’re not doing this kind of convoluted form testing, you probably don’t need this update.

PalmCUnit 1.2.1

I’ve found that the application ID that PalmCUnit was using (STRT) is a default ID that is generated by CodeWarrior. Since I don’t use CW, I didn’t notice this. I’ve changed the ID to UntT, which I’ve registered at PalmSource.

No new features have been added to 1.2.

PalmCUnit 1.2

I’ve added a small preferences database that will allow you to set a checkbox that causes the testrunner to automatically run all its tests when it is run.

This has turned out to be very nice for my programming in Falch’s Developer Studio. I can just punch one button in the GUI and all my unit tests run!

palmcunit-showprefs.jpg Check the box if you want your tests to automatically run whenever you launch the tester.

PalmCUnit 1.1

Basic feature list for version 1.1:

  • PalmCUnit is now a multisegmented app. This allows it to test a larger code base.
  • The code has been restructured to place all the source in the same directory. This allows for much simpler debugging of source that gets away from you!
  • PalmCUnit now has the green/red progress bar that has become standard among other test runners (CppUnit, JUnit, etc.).
  • There are now pre-test and post-test function callbacks. Before there were only pre- and post- test suite callback functions.
  • I added many more ASSERT macros. There should be enough for most programming needs at this point:
    • FAIL()
    • ASSERT(cond)
    • ASSERT_MSG(msg,cond)
    • ASSERT_INT8_EQUAL(exp,act)
    • ASSERT_INT8_EQUAL_MSG(msg,exp,act)
    • ASSERT_UINT8_EQUAL(exp,act)
    • ASSERT_UINT8_EQUAL_MSG(msg,exp,act)
    • ASSERT_INT16_EQUAL(exp,act)
    • ASSERT_INT16_EQUAL_MSG(msg,exp,act)
    • ASSERT_UINT16_EQUAL(exp,act)
    • ASSERT_UINT16_EQUAL_MSG(msg,exp,act)
    • ASSERT_INT32_EQUAL(exp,act)
    • ASSERT_INT32_EQUAL_MSG(msg,exp,act)
    • ASSERT_UINT32_EQUAL(exp,act)
    • ASSERT_UINT32_EQUAL_MSG(msg,exp,act)
    • ASSERT_STR_EQUAL(exp,act)
    • ASSERT_STR_EQUAL_MSG(msg,exp,act)