Enabling Assertions in Eclipse

From EQUIS Lab Wiki

Jump to: navigation, search

Assertions are one of the most useful tools available to software engineers to help debug their code. Unfortunately, Eclipse has assertion checking turned off by default. This means that even if assertions fail, no error will be produced.

To turn assertions on, go to Window|Preferences. In the dialogue that appears, select Installed JRE's. The dialogue should look like this:

installedJREs.png

Select your JRE, and click Edit. You will come to a dialogue that looks like this:

dash-ea.png

Enter -ea under Default VM Arguments. Click Ok to save the change.

Your assertions will now be checked when you run your programs under Eclipse.