JBuilder now, as of version 6 has JUnit integrated, and includes a JBuilder
TestRunner that opens a multi-pane subwindow for test results. Pretty nifty --
StevenNewton
I am currently
learning to
UnitTest as it fits with
ExtremeProgramming. Since I am using JBuilder as my IDE, and JUnit (
JavaUnit) and
HttpUnit as my test suites, I thought I'd document my progress here so others could follow. --
CurtisCooley
OK, here is what I have done so far.
This assumes that you have a JBuilder project that you want to use JUnit to test.
- Add junit.jar as a required library
- Create a class that will be your testing class
- Create a Run Configuration to run the test class
- Open Run Menu
- Choose Configurations
- Create a new one. I name mine 'test'
- Use your test class as your startup (main) class
When you want to run a unit test, just select 'test' from the run button's pull down menu and the test results print in the run pane if you call the textui
TestRunner.
Clear as mud? Please post questions so I can clear this up, or better yet, post a better way. :)
--
CurtisCooley
I am in the same situation. May I contribute? --
JoiEllis
Please do. I got the testui version working this morning. I don't know about the auto-reloading of classes for the swingui version like in Visual Age.
Okay, I've written up something which turned out to be rather long. I've
placed it into its own page,
JunitWithJbuilderInstall to keep this page cleaner.
Having read this page and
JunitWithJbuilderInstall, has anybody actually got JUnit working from the Tools menu. We've tried to get it to use the currently open file as the test class, but with no success. We've managed to get JRefactory's pretty printer working from there, to deal with JBuilder's poor formatting.
I didn't really try to get JUnit working with JBuilder's Tools Menu. My goal was to create a run configuration that I could use to run all the unit tests. I can see that I'll need multiple configurations as the project grows, but I'll cross that road when I come to it (YAGNI). --
CurtisCooley
I haven't seen a need to run it from the tools menu.
I have created a simple JUnit extension for JBuilder.
http://home.carolina.rr.com/mitrovic/junit
Ivan Mitrovic
There is an Open Tool for JUnit on:
http://andersnorlin.tripod.com/. It's under Testing.
The site has been gone for the last few days..
I use
JunitWithJbuilder by setting the default runnable node to be my
TestAll class. This has a main method which invokes the JUnit textui
TestRunner. The output comes out at the bottom of the screen so I don't have to switch windows. All I have to do is hit F9 to run all my tests. --
AndrewSwan
I also like
JunitWithJbuilder. It's very easy to setup and use. Also, I don't use a default runnable node. All my
TestCase classes subclass an Abstract
TestCase that has a static main. I then have a class called
PackageTestSuite in every package that simply adds the class object for each of the former to a suite object - this also has a static main. Here's an elided example:
package com.tripwre.adt;
import junit.framework;
public class PackageTestSuite
{
public static Test suite()
{
TestSuite suite = new TestSuite( "com.tripwire.adt" );
suite.addTest( new TestSuite( ItemArrayTest.class ) );
suite.addTest( new TestSuite( ItemListTest.class ) );
suite.addTest( new TestSuite( DNodeListTest.class ) );
suite.addTest( new TestSuite( SNodeListTest.class ) );
return suite;
}
public static void main( String[] args )
{
junit.textui.TestRunner.run( suite() );
}
}
As you can see, this if very simple. Each time I create a new
TestCase, I add it to the
PackageTestSuite in that directory/package.
Finally, each complete project/package-collection has a class named
ProjectTestSuite. This is pretty much like the above but adds the answer to
suite for each
PackageTestSuite in the system.
When I'm in refactoring or programming mode, I will simply right click on the
TestCase for the class I am working on and select
Debug or
Run. In
Daily Build mode, I
Debug or
Run the
ProjectTestSuite class (this is usually done by the last line in the daily-build script). Occasionally, I will right click on various
PackageTestSuite classes and select
Debug or
Run. BTW, these are the actual class names, so if I have a package named
com.tripwire.adt, the
TestSuite for all of its classes is called
com.tripwire.adt.PackageTestSuite.
It's very simple to create an use tests. Because I
CodeUnitTestFirst, I need to be able to right click on any class, package, or project test and run or debug it. This makes that easy. I also context switch between a
foo project and a
foo_test project so that while a
TestCase shares the same package as its
ClassUnderTest (hence looking like part of the same system to the workspace), a
TestCase is actually saved in a different directory from the
ClassUnderTest. See
JunitWithJbuilderInstall for ideas on who various people setup and use Junit with JBuilder.
--
RobertDiFalco