PBUnit/PowerUnit Quick Start
Posted by Frank Mao on February 5, 2008
- Download latest version. To eliminate confusion, I bumped up the version number to 9, to indicate this is to PowerBuilder version 9. You should be able to upgrade/migrate this to any Powerbuilder version higher than 9.
- Create your demo app, add pbunitfunc.pbl and pbunit.pbl into your app’s lib list.

- Create a nvo, this is the object to be tested later.

- OK, let create our first PowerBuilder test case. You have 2 options to put all test cases, a) same target as the demo app; b) create a different target to hold all test cases. (This needs duplicate all app settings in your new application object, especially for pfc app) To make it easier to start, we use the same target, which means testing object and tested object are in same project.
Test case object needs to inherit from testcase object in pbunit.pbl.
- The code in test case looks like this:

- Save this testcase object as n_cst_math_service_tests. To make auto-test run, I set a rule: all test case object should end up with ‘tests’, unless I can find a way to detect the ancestor of PowerBuilder’s object.
- Launch your pbunit.exe. Load this new target.Click ‘Run’ button. You should see your green bar now. Note, the ‘Run All’ button is for auto-run usage, a xml test result file is generated afterwards. Then can be embedded into CouriseControl continues auto build server.

Erik Swanson said
Hi Frank,
I’ve got the latest version of PBUnit (20080714), so there are at least two of us using it.
However, i’m having the following problem: as I debug, the app hangs in pbunit in
of_getcurrenttest() at line:
inv_test = create using is_CurrentTestObject
..
I’ve tried to let it run for 5 minutes or so, but it should never take that long to load a simple test case. Any ideas?
Thanks,
Erik Swanson
Frank Mao said
Great, I feel a little bit warmer now.
PBUnit can only run in exe mode. Debug mode never worked. Don’t know why, please try launch executable and make sure it’s the right PowerBuilder version.
Erik Swanson said
Hmm.. I have 11.5, trying to get it working in that, not 9. I’ll try to rebuild and redeploy .exe and check if that works. Thanks for the tip!