user697911 user697911 - 1 month ago 21
Java Question

Why doesn't my assert doesn't work in IntelliJ?

In my Custom VM options in My IntelliJ, I have "-ea" in my idea64.exe.vmoptions. But why doesn't this report assertion error:

int a = 1;
int b = 2;

Answer Source

The idea64.exe.vmoptions defines the java options which IntelliJ itself launches with; not what a given run configuration will launch with.

Once you've launched your program (via the little play icon next to your main method), it should appear in the run configurations drop down at the top. If you go edit this, and add -ea to the VM Options field, you can then run it with assertions enabled.