1package org.junit; 2 3import java.lang.annotation.ElementType; 4import java.lang.annotation.Retention; 5import java.lang.annotation.RetentionPolicy; 6import java.lang.annotation.Target; 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>@Before</code> causes that method to be run before the {@link org.junit.Test} method. 12 * The <code>@Before</code> methods of superclasses will be run before those of the current class. 13 * No other ordering is defined. 14 * </p> 15 * 16 * Here is a simple example: 17 * <pre> 18 * public class Example { 19 * List empty; 20 * @Before public void initialize() { 21 * empty= new ArrayList(); 22 * } 23 * @Test public void size() { 24 * ... 25 * } 26 * @Test public void remove() { 27 * ... 28 * } 29 * } 30 * </pre> 31 * 32 * @see org.junit.BeforeClass 33 * @see org.junit.After 34 */ 35@Retention(RetentionPolicy.RUNTIME) 36@Target(ElementType.METHOD) 37public @interface Before { 38} 39 40