My unit tests use the main
entry point in each of my Java classes. I'm using Eclipse. It's been risky to rely on the test results because sometimes I've forgotten to set -enableassertions
in the JVM arguments. Is there a universal setting that applies to all current and future Run Configurations
?
To make assertions enabled by default, first go to the Eclipse menu named Window
because Eclipse is a GUI application so it seems to be an excellent reason to put it in a menu called "Window".
Window > Preferences > Java > Installed JREs
Select the JRE that you use.
Click Edit
. Add to the Default VM Arguments
textbox the option -enableassertions
. Click Apply
if necessary.
Now, even without enabling assertions in the launch configuration, which seems to be synonymous with run configuration, programs run in Eclipse will have assertions enabled.