All the test primitives described here are available for both J2SE and J2ME versions of the JUnit testing framework.
This section describes each method used by Component Testing for Java, including:
Syntax
Functionality and rules governing its usage
Examples of use
Notation Conventions
Throughout this guide, command notation and argument parameters use the following standard convention:
Notation |
Example |
Meaning |
BOLD |
BEGIN |
Language keyword |
<italic> |
<string> |
Symbolic variables |
[ ] |
[<option>] |
Optional items |
{ } |
{<string>} |
Series of values |
[{ }] |
[{<string>}] |
Optional series of variables |
| |
on | off |
OR operator |
JUnit Assert Primitives
Component testing for Java uses the standard assert test primitives provided by JUnit. Please refer to documentation provided with JUnit documentation for further information.
Method |
Purpose |
Checks that two values are equal | |
Checks that an object is not null | |
Checks that an object is null | |
Checks that two object are actually the same | |
Checks that a condition is true | |
Marks a test as Failed |
Extended Primitives
Component Testing for Java extends the set of assert test primitives provided by JUnit with a special set of verify primitives. These extended test methods are part of the TestCase class. User test classes must derive from TestCase to use these primitives.
Method |
Purpose |
Checks that two values are equal | |
Checks that an object is not null | |
Checks that an object is null | |
Checks that two object are actually the same | |
Checks that a condition is true | |
Checks that an exception is thrown | |
Checks that two variables have the same value within a given margin | |
Checks that a tested value is strictly greater than a reference value | |
Checks that a tested value is greater or equal to reference value | |
Checks that a tested value is strictly lower than a reference value | |
Checks that a tested value is lower or equal to reference value | |
Logs a message in the test report | |
Marks a test as Failed with a message |
Timer Primitives
Component Testing for Java provides multiple timer control primitives, allowing you to perform basic performance testing.
Method |
Purpose |
Creates a timer | |
Starts a timer | |
Logs the elapsed time since a timer was started | |
Checks that the elapsed time for a timer is below a given value |