• Post Reply Bookmark Topic Watch Topic
  • New Topic

Annotations  RSS feed

 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can someone give me an exmaple source code about the use of annotations ?
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. JUnit 4 uses annotations to determine what methods are test methods.



In the above code, testMethodA will be run as a test method since it is annotated with the @Test annotation, where anotherTestMethod will not since it does not have the annotation.

Note this only works with JUnit4.x (since JUnit3 considered any method that started with the word test to be a test method).
 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we make use of annotations ourselves? What is the procedure to add annotations into our own applications, like JUnit?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everybody.
[ August 25, 2007: Message edited by: Yohan Liyanage ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!