From: JunitWithIdes
Tips and tricks for using JUnit with VisualAge. Its a little different (better?) in some ways from a standard IDE. --DavidRees
JUnit works with VisualAgeJava. The JUnit distribution includes some instructions on how to do this; essentially, you add a "JUnit" tool to the popup menu for the workspace and classes. When you run the JUnit tool for a class, it pops open the graphical test runner and automatically runs that class as a test suite.
The only irritating thing about running JUnit in visual age is that some changes to code under test (e.g. removing member variables) sometimes causes JUnit to vanish, so you have to re-open it. It's not very irritating.
Basic instructions for installing/using JUnit with VisualAge are located at http://www.junit.org/junit/doc/vaj/vaj.htm.
Note there seems to be a change/bug in VAJ 3.5 that requires you to use the full directory path of the project_resources directory of a Project rather than just its name in the Workspace classpath. So instead of "JUnit" you might have d:\Java\VisualAge\ide\project_resources\junit. Note that (as the above link says with this caveat) you will also need to include project_resources directory for any Projects you want to test.
This bug and workaround was reported by EricRizzo? on usenet at http://x68.deja.com/getdoc.xp?AN=645905775&CONTEXT=974447408.958660643&hitnum=0
Ok, now a question. What approach are people using for OrganizingTestCases in VisualAge. Unfortunately the multiple CLASSPATH approach will not work. Assuming we do want to access protected members then different packages will not work. From what I have read so far the best approach seems to be PeterMaier's (hi Peter). That is to put them in the same package and then use a naming convention to strip them out later. I would like another approach, but this seems much cleaner than SubclassToTest.
Another possibility for stripping test cases out for export is to have all test cases implement the BeanInfo? interface. You create a superclass for all your test cases that provides the empty method implementations. On the export dialog there is a button to de-select all BeanInfo? and PropertyEditor? classes.
I sure do miss Smalltalk extensions.--DavidRees
JunitCreator is a tool for VisualAge Java that automatically creates JavaUnit test case templates.
I have found a trick for arranging Junit 3.2 and VisualAge 3.5.
Step1) under tools folder of VisualAge create a folder called junit. Then copy inside default.ini (from Junit distribution) and unjar junit.jar inside it (it is not necessary to import JUnit into the workspace folder)
Step2) restart VisualAge
Step3) Set as Extension projects all the projects that you want to use with JUnit tool (i.e. projects with your testcases !) (In previous VisalAge? you was used to setup workspace resource instead !)
Step4) Run Junit :-)
Hope this help Piero Campanelli (pcampanelli@acm.org)
* How to stop the debugger on your failing assert() Select menu item (for VAJ 3.5 menus): Window | Debug | Debugger When the debugger opens, Select the "Exceptions" tab. This shows a list of exceptions. find and select "AsserstionFailedError?::junit.framework" Thereafter, when junit throws an error the debugger will stop on it. Step down a few stack frames and you'll see the exact assertion that failed. Pretty cool huh?- MarkWindholtz