Community
Participate
Working Groups
Analouge to a bug in Netbeans (https://netbeans.org/bugzilla/show_bug.cgi?id=175517) asserations should be activated by default. So intellij idea enables asserations in junit tests, netbeans does, maven does and many many more. Only eclipse does not. Step 1 1. Create empty junit test. 2. Insert `assert false;` 3. Execute test. Expected: Test failure.
Since assertions are off by default we run JUnit with the same default, but you can enable this on the 'JUnit' preference page.
Official documentation (JLS7 in page 378) sais: Typically, assertion-checking is enabled during program development and testing, and disabled for deployment, to improve performance. I do not accpet that Java, Oracle, Maven, IntelliJ, Ant, NetBeans and all the other development tools are wrong.
I think changing the default for JUnit runs makes a lot of sense.
(In reply to Peter from comment #2) > Official documentation (JLS7 in page 378) sais: > Typically, assertion-checking is enabled during program development and > testing, and disabled for deployment, to improve performance. Good point. Default was chosen in bug 45408 comment 27.
Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=8a5afa464b6bab19deb769751f45c21b099dfa8a Note that the new default only affects new launch configurations.
I'm getting a test failure now: TestEnableAssertions.testAssertionsOffByDefault Looks like this test should be changed...
(In reply to Till Brychcy from comment #6) > I'm getting a test failure now: > TestEnableAssertions.testAssertionsOffByDefault > Looks like this test should be changed... re-opening
Why did the unit test fail? Did you enabled asserations before unittest? No? They should be activated by default, if they are not enabled by default maybe its a bug in the IDE you use. Oh, here we go, its this bug i guess: https://bugs.eclipse.org/bugs/show_bug.cgi?id=479553 Oh, Déjà vu!
Updated the test case: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=8a7cc6f68c54a92482c554c4c899979b5c1ba713
Thanks Noopur.
Thanks Noopur, luckily the test does not use the built-in assert-keyword because there was a bug inside eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=479553 :p