Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to enable Assertions in eclipse

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to use assertions to test my assumptions. But I wanna do that using Eclipse IDE. is there a way I can eanble assertions in eclipse?/

Thanks.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, you want to pass an argument (-ea) to the VM. How to do this might vary depending on your version of Eclipse, but here's how it works in Eclipse Europa...
  • Open the Run Dialog (this should be an option under the "Run" menu).
  • Click on the tab, "(x)= Arguments."
  • In the field for "VM arguments," enter -ea to enable assertions.
  • Click on the "Apply" button.
  •  
    Arjun Reddy
    Ranch Hand
    Posts: 629
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Yep got it. That's something new I learnt today. Thanks Marc.
     
    Gaurav .Singh
    Greenhorn
    Posts: 8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What about Eclipse Ganymede??
     
    Seetharaman Venkatasamy
    Ranch Hand
    Posts: 5575
    Eclipse IDE Java Windows XP
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Gaurav .Singh wrote:What about Eclipse Ganymede??


    It is common to all the versions[ganymade, galileo ... etc] of eclipse . whether i got your question or not ?
     
    Gaurav .Singh
    Greenhorn
    Posts: 8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    yes i understood it thanls...
     
    Michael P Carter
    Greenhorn
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You can enable assertions for Junit thus:

    Window -> Preferences -> Java -> JUnit -> check the box at the top of the dialog labelled "Add '-ea' to VM arguments".
     
    Campbell Ritchie
    Sheriff
    Pie
    Posts: 49733
    69
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I think this thread might fit better in the IDEs forum, so shall move it.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic