Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
assert(a==b)
like image 460
user697911 Avatar asked Jan 04 '23 14:01

user697911


2 Answers

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.

like image 61
BeUndead Avatar answered Jan 06 '23 03:01

BeUndead


For Intellij 19.2 community version, I found the VM option to add -ea via going to top menu and following Run -> Edit Configurations... -> VM options:

like image 42
giyoon21c Avatar answered Jan 06 '23 03:01

giyoon21c