Enabling Assertions in jGrasp:
To enable assertions in jGrasp:
- Click on "Settings" in the bar of menu items.
- Hover over "Compiler Settings" on the dropdown menu,
and click on "Workspace".
- On the window that appears, click on "Flags/Args".
- On the form that appears, go to the row labeled "Run" and in the
text box in the second column (labeled "FLAGS2 OR ARGS2"),
enter "-ea" (not including the quotes).
(If you prefer, you can enter the longer version, which is
"-enableassertions".)
However, before you can enter text into the box, you'll have to
click on the smaller box next to it, which has a black dot inside.
Doing so should make the little black dot disappear,
at which point you can enter text into the text box.
- Click on "Apply" (at bottom), and then click on "OK".
To verify that assertion testing is turned on, try running the
AssertTest program.
It should abort due to an AssertionError.
If it does not, it means that assertion testing has not been
turned on.
Note:
In the less likely event that you are running a Java program
from the command line (using the java command),
to enable assertions you need to include the -ea
(or the more verbose -enableassertions) option.
For example, if you were running a program named Multiply
you would enter
java -ea Multiply
End of note.