Dynamic Analysis Suppressions
In general, the best way to prevent Jtest from reporting exceptions that are not relevant to the class under test is to document the class's permissible inputs and/or expected exceptions using Design by Contract tags. This way, the class's implicit contracts are documented in the code itself. For information about using these tags to suppress exceptions, see Customizing White-Box Testing
Another preferred way to stop Jtest from displaying certain uncaught runtime exceptions, specification errors, and regression errors is to right-click the appropriate message in the Errors Found panel of the Class Testing UI or in the Results panel of the Project Testing UI, then choose one of the following commands from the shortcut menu:
- Not an Error: Choose this command to indicate that a reported problem is not an error, but rather is the class's correct behavior (for that input).
- Ignore: Choose this command to tell Jtest to ignore the problem reported for this input. If this is selected, the outcome will not be used for comparisons when searching for specification or regression errors. Also, no uncaught runtime exceptions will be reported for this input.
You can also suppress the reporting of uncaught runtime exceptions in two ways:
- Adding a suppression from the Errors Found panel or Results panel.
- Adding a suppression directly to the Dynamic Analysis Suppressions Table.
To suppress a particular exception that appears in the Errors Found panel or Results panel, right-click the exception that you want suppress, and choose Suppress from the shortcut menu. This action will add that specific exception to the Dynamic Analysis Suppressions Table.
You can enable or disable checking for certain types of exceptions in the Pre-filtering Suppressions Categories node (located under Dynamic Analysis> Test Case Execution) of the Global, Project, or Class Test Parameters.
The Dynamic Analysis Suppressions Table lets you create new suppression categories for uncaught runtime exceptions. You can use this option to suppress the reporting of exceptions by class, method, and exception type.
Opening the Suppressions Table
To reach the Suppressions Table, double-click the Suppressions Table node in the Dynamic Analysis branch of the Global Test Parameters tree.
Adding a Suppression to the Dynamic Analysis Suppressions Table
- Right-click any area of the table. A shortcut menu will open.
- Choose Add New Suppression from the shortcut menu. An empty table entry will open.
- In the empty table entry, enter the exception, the method that throws it, or the class that declares the method that you want to suppress.
Important: Make sure that you type all values exactly as they appear in the Jtest UI.
Suppressing Specific Exceptions by Class, Method, and Exception Type
To suppress specific exceptions by class, method, and exception type, enter the information in the appropriate fields. For example, to suppress the ArrayIndexOutOfBoundsException from the 'setSize' method of java.util.Vector, use:
Suppressing Exceptions by Class
To suppress exceptions by class, enter the classname in the Class field by double clicking that field and then entering the fully qualified classname.
Use the '*' (asterisk) symbol to match any letter. For example, to suppress all exceptions from the class java.util.Vector, use:
java.util.Vector | * | *
Suppressing Exceptions by Method
To suppress exceptions by method, enter the method name in the Method field by double-clicking that field then entering the method name. To suppress exceptions from a single method belonging to a set of overloaded methods, specify the method by including its signature enclosed in parentheses. Method signatures should follow the JNI specification from the JDK (minus the return type). For example, to suppress exceptions from the following method
(int n, String s, int []ia)
use the following as the method signature:
(ILJava/lang/String;[I)
Suppressing Exceptions by Exception Type
To suppress exceptions by exception type, enter the exception type in the Exception field by double clicking that field and then entering the exception type.
Use the '*' (asterisk) symbol to match any letter. For example, to suppress all NullPointerExceptions use:
Removing a Suppression
- Right-click the table entry. A shortcut menu will open.
- Choose Delete from the shortcut menu.
Note: To delete a list of suppressions, right-click drag from the first suppression to the final one, then release the mouse button. A shortcut menu will open. Choose Delete from the shortcut menu.
Viewing the Results
Suppressions in this list are applied when the results are displayed. Results are displayed after you click the Start button, generate the report file, or view results in the Results UI.
Related Topics
Customizing White-Box Testing
Static Analysis Suppressions
|