There are a number of actions that can be taken when an assertion fires. These actions, called behaviors, can be determined by the user. Both the C++ and the Java tool support behaviors that allow the user to specify whether to continue, terminate, or ignore when an assertion fires. The C++ tool adds the capability to have the program pause in its execution. The Java tool gives the user the option of having the output from the terminate or continue behavior go to either stdout or to a special pop-up window that the user must close.
The most common behavior that will be used is the terminate behavior. This behavior causes a program to cease execution after an assertion statement has fired and printed its output. Since the firing of an assertion indicates a bug in the code, it is usually desirable to stop execution at this point instead of continuing onward.
The continue option causes the program to continue execution even after an assertion statement has fired. It prints the output that it normally would, and then continues with the program (possibly causing more assertion statements to fire later). This behavior might be useful for things such as tracing the propagation of an error through a program or for collecting the output of a program in a file (possibly for testing purposes).
The ignore behavior causes an evaluated assertion to produce no output. This is different from removing the assertions from the source code (talked about later) because the assertion statement is still evaluated.
The pause behavior (C++ only) results in output being printed as usual, and the program being put into a paused state. This is a useful debugging tool because, by using the process ID that is given, the user can load the paused program into a debugger. Since the program has not yet terminated, the programmer has access to the complete state of the program at the time that the assertion was fired, and the programmer can use this information to determine what caused the firing of the assertion. Each of these behaviors can be configured at either compile time or run time. This enables the user to compile a program once, and run it using various behavior settings. In addition to these behavior settings, there are other options that affect assertion statements. Each of the assertion types may be turned on or off independently. The user may also choose to turn off at compile time. When the assertions are turned off, they are not compiled as part of the source code. This is most useful when a program has been thoroughly tested, and is being made ready for release.