Study guide: Tools of the trade, Part 2
Brush up on Java terms, learn tips and cautions, review homework assignments, and read Jeff's answers to student questions
By Jeff Friesen, JavaWorld.com, 12/06/02
Glossary of terms
- black-box testing
- A form of dynamic analysis that determines whether a class's public interface performs to specification.
- class test parameters
- Configurable test settings that apply to a specific class.
- dynamic analysis
- A form of testing that executes a program, provides that program's input data, and examines the program's output to determine
whether the program executes correctly.
- global test parameters
- Configurable test settings common to classes and projects.
- project test parameters
- Configurable test settings that apply to a specific set of classes.
- regression testing
- A form of dynamic analysis that tests modified code with the same set of inputs and test parameters that previous tests used.
- static analysis
- A form of testing that examines executable code or equivalent source code to learn if that code conforms to industry-standard
guidelines.
- stubs
- Stripped-down methods that execute code to support testing instead of their own tasks. (Can also apply to classes.)
- test cases
- Sets of input data for a program to process.
- testing
- The analysis of source/executable code and the controlled execution of executable code to reveal defects that compromise a
Java program's executable integrity.
- white-box testing
- A form of dynamic analysis that determines whether a program's classes are structurally sound.
Tips and cautions
These tips and cautions will help you write better programs and save you from agonizing over why the compiler produces error
messages.
Tips
- To view a professional report of test results (after the current test session's various static and/or dynamic analysis tests
complete), choose the Report menu item from the View menu.
- You can further refine static analysis testing to a built-in or user-defined category by choosing the appropriate menu item
from Static Analysis's associated pop-up menu. (The same applies to the Dynamic Analysis menu item, but you choose between
automatic and user-defined dynamic analysis.)
- Some test parameters in either the Class Test Parameters or Project Test Parameters windows display inherit beside the test parameter name. That means either the class or project test parameter inherits its setting from an equivalent
global test parameter. To override this setting, click the test parameter value until it displays the appropriate override
setting (such as a Boolean test parameter's true or false).
Cautions
- Jtest does not perform static analysis on a classfile if its source file is missing and the Class Testing UI is the current
testing UI.
- When using DBC (Design by Contract) with a method, do not place the DBC Javadoc comment(s) inside the method body. Otherwise,
Jtest will not black-box test the method.
Homework
- Rewrite
Lines.java to remove all static analysis violations. Use Jtest for verification.
Answers to last month's homework
Last month, I asked you to answer some questions about JCreator. Here are my answers (which appear in red).
- What is a project template?
-
A project template is a file of prewritten source code and special symbols that customize the source code to a specific project.
- What is a code template?
-
A code template pairs an abbreviation with a code sequence. When you type the abbreviation followed by the Tab key, JCreator's
editor replaces the abbreviation with the code sequence.
- What is a JDK profile?
-
A JDK profile is a configuration item that identifies an installed version of a Java JDK/SDK. Each project can have its own
JDK profile.
- How do you set the classpath?
-
To bring additional package directories or jar files into a project, you set the classpath by completing the following steps:
- Select Project Settings from the Project menu.
- Select the Required Libraries tab on the Project Settings dialog box.
- Click the New button to display the Set Library dialog box.
- Click the Add button and choose the appropriate jar file or the directory that contains the package directory.
- Specify an arbitrary name to identify the package and click the OK button.
- From the list in which the package name appears, check the associated checkbox. That check adds the package directory (or
jar filename) to the classpath.
- Click the OK button on the Project Settings dialog box to save project settings.
- How do you pass command-line arguments to an application?
-
The following steps let you pass command-line arguments to an application:
- Select Options from the Configure menu.
- From the Options dialog box, select JDK Tools in the Options tree.
- Make sure the Select Tool Type drop-down list-box on the JDK Tools panel displays Run Application.
- Select an existing tool configuration by clicking the Edit button. (Or create a new tool configuration by clicking the New
button.)
- From the Tool Configuration dialog box, select the Parameters tab.
- Check the Prompt For Main Method Arguments checkbox.
- Back out of the dialog boxes by clicking their OK buttons.
- How do you add the
-g debugging option to javac from within JCreator?
-
Complete the following steps to add the -g debugging option to javac, so the compiler generates all debugging information:
- Select Project Settings from the Project menu.
- From the Project Settings dialog box, select the appropriate JDK profile on the JDK Profiles tab, and select the JDK Tools
tab.
- From the JDK Tools tab, make sure the Select Tool Type drop-down list-box displays Compiler. Choose the appropriate tool configuration
(for the previously-chosen JDK profile) and click the Edit button.
- From the Tool Configuration dialog box, select the Parameters tab and check the Include Debug-Info checkbox.
- Back out of the dialog boxes by clicking their OK buttons.
Prior to compiling, make sure the appropriate JDK profile and tool configuration entries are checked on their respective Project
Settings tabs so that all debug information generates.
Read more about Tools & Methods in JavaWorld's Tools & Methods section.