Creating JUnit Tests from The Contextual Menu
Document History:
This document is based on a document created by Rudolf Bock on
October 23th 2004, placed at
http://ui.netbeans.org/docs/ui/junits/context_creating.html.
CVS status:
$Revision: 1.2 $
| $Date: 2005/04/25 17:39:00 $
| CVS history
Table of Contents:
In the NetBeans IDE, there are several ways of how to initiate creation of
test classes. You can use the New... wizard and
create an empty test case, a test case for an existing class or a test
suite. Another way of creating test classes is by selecting a source
folder/package or individual file and selecting action Tools 〉 JUnit Tests 〉 Create Tests, which
opens a configuration dialog. You can set the basic parameters of the
created test class using checkboxes.

Current configuration form
Unfortunately the dialog has a couple of weak points:
- it is inconsistent with the JUnit wizard dialogs
- it does not allow to specify target destination package where created
test classes should be put
The center part of the form has a similar functionality like the current
version. If you create a test class for a package, you can specify the
class types. In other cases these checkboxes do not figure in the form.
Contents of sections A, B, C, D can change according to the current
selection of classes/packages/folders and user's interaction.
New configuration form
Section A:
This place shows information about the source for the created test class.
If the source is a single source class, the displayed text looks like
Class to Test: 〈class name〉.
If the specified source is a package, the displayed text can be
Package: 〈package name〉.
If the source consists of several classes, the displayed text should be
More than one class is selected... and section
C should be displayed.
Section B:
In this section, the user can set name of the created test class and
a target source root.
Section C:
This section is displayed only if at least one package and/or folder is
selected or if multiple individual classes are selected.
Section D:
This area is reserved for warnings and user-interaction dependent
information. You can find a similar area in the wizard dialogs.
When the Show Create Tests Configuration Dialog
checkbox is unselected, a message about possibility to recover this dialog
in the NetBeans preferences is displayed. In contrast to the Wizard
dialog, the info area is placed next the Section B, because it is
important that the user acknowledges consequence of some settings.
1. The wizard form for creating test classes includes fields where you can
type data and another one for display purposes only. The second one
represents a problem. On MacOS look & feel, it is focusable and looks
like editable but it is not editable nor the user can copy information
from it.
Suggested solution: On all platforms should be these elements
not-enterable. These element should look like disabled.
2. Another design flaw is the default size of the wizard window. The same
UI elements on different platforms can have different sizes and that
sometimes leads to inconsistency. The picture shows a form page where
one checkbox (Optional Comments) is hidden when
MacOS look & feel. It is displayed correctly on Windows L&F.
Suggested solution: Set (increase) the default size of all windows
so that all UI elements fit on every platform.
3. The picture bellow shows a wizard page with a warning message displayed
at the bottom. The message is too long to fit on one line and is clipped
(ending with an ellipsis at the end). The message is so long that it does
not fit even if the user resizes the wizard dialog to the maximum
width.
Suggested solution: Verify that all forms use text-wrappable
elements for displaying messages.