• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trying to get AssertionError  RSS feed

 
Sami Devine
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am trying to get AssertionError. Why does the following run?


 
Yunnan Zhou
Ranch Hand
Posts: 31
C++ Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your junit Test must be like this

check you jar file
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yunnan Zhou wrote:your junit Test must be like this


Indeed, that would be a JUnit test; but we're talking about Java assertions, another topic altogether.

Assertions are turned off by default; you must enable them by providing the -ea switch to java when you run it:

 
Sami Devine
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest, thank you. this worked.
Yunnan thanks
 
Yunnan Zhou
Ranch Hand
Posts: 31
C++ Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it .
I looked up some materials.
if you assert false, a java.lang.AssertionError will be throwed,and if you assert true,it will run well
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you have to enable assertions as Ernest has shown.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!