KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > junit > Before


1 package org.junit;
2
3 import java.lang.annotation.ElementType JavaDoc;
4 import java.lang.annotation.Retention JavaDoc;
5 import java.lang.annotation.RetentionPolicy JavaDoc;
6 import java.lang.annotation.Target JavaDoc;
7
8 /**
9  * <p>When writing tests, it is common to find that several tests need similar
10  * objects created before they can run. Annotating a <code>public void</code> method
11  * with <code>&#064;Before</code> causes that method to be run before the {@link org.junit.Test} method.
12  * The <code>&#064;Before</code> methods of superclasses will be run before those of the current class.</p>
13  *
14  * Here is a simple example:
15  * <pre>
16  * public class Example {
17  * List empty;
18  * &#064;Before public void initialize() {
19  * empty= new ArrayList();
20  * }
21  * &#064;Test public void size() {
22  * ...
23  * }
24  * &#064;Test public void remove() {
25  * ...
26  * }
27  * }
28  * </pre>
29  *
30  * @see org.junit.BeforeClass
31  * @see org.junit.After
32  */

33 @Retention JavaDoc(RetentionPolicy.RUNTIME)
34 @Target JavaDoc(ElementType.METHOD)
35 public @interface Before {
36 }
37
38
Popular Tags