View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

SUnit Testing Guide - Yahao Wu

It actually took me a good bit to figure out how to get the SUnit testing to work in VisualWorks, so here’s a guide on pretty much what I did.

First off, open up VisualWorks. From there press F5 to access the system browser. Look for the package called SUnit. It should be towards the bottom since the packages are organized alphabetically. If for some reason you don’t have it, you can easily download it from the cincom repository. Simply connect to the repository and open up the ‘published items’ window, and then find and load the SUnit package.

Now, go to the package that you want to use SUnit testing on and create a new class. For the sake of this guide, I’ll name mine SUnitTest. Make sure that the superclass is set to #{XProgramming.SUnit.TestCase} so that you can access all of the SUnit methods. This class that you just create can now be shown on the dropdown whenever you run the TestRunner.

To set up the actual testing, you have to create an instance group called “initialize-release” that has the method “initialize” that has all of the variables that you will be using to test.

Now create a new instance group where you will be testing all of your classes. Each of your tests should be specific to one class each. Make sure to test every single method in that class (excluding getters and setters) so that you are certain that they will work. You can skip classes that only have getters and setters since those are rather unnecessary, but try to test everything else. The two most helpful keywords that you should know are “assert” and “deny”. Assert tests if the case is true, and deny if it’s false.

Running the TestRunner to test your SUnit is pretty straightforward as well. Simply go to your workspace, and open up an empty page. Then type in “TestRunner open” and then run it. The TestRunner window will open. Select your class that you created earlier from the dropdown menu, and then click “Run”. If your class works, then “Pass” should be shown, if not then “Fail” will be shown. If your class doesn’t work then you can select your class from the dropdown menu on the bottom and click “debug”. This will allow you to debug your class while testing it.

That it! If you’re still confused about how to get SUnit working, then you can take a look through the repository for some TestCase examples, or check out other guides to SUnit testing in the case.

Good Luck!

Links to this Page