001/**
002 * Powerunit - A JDK1.8 test framework
003 * Copyright (C) 2014 Mathieu Boretti.
004 *
005 * This file is part of Powerunit
006 *
007 * Powerunit is free software: you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published by
009 * the Free Software Foundation, either version 3 of the License, or
010 * (at your option) any later version.
011 *
012 * Powerunit is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015 * GNU General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with Powerunit. If not, see <http://www.gnu.org/licenses/>.
019 */
020package ch.powerunit;
021
022import java.lang.annotation.Documented;
023import java.lang.annotation.ElementType;
024import java.lang.annotation.Retention;
025import java.lang.annotation.RetentionPolicy;
026import java.lang.annotation.Target;
027
028/**
029 * Mark a field as the test rule chain.
030 * <p>
031 * This field must be public, final, non static and of type {@link TestRule}.
032 * This annotation can be used only once on a class.
033 * <p>
034 * In case one test class extends another one, it is possible to have one field
035 * annotated with this annotation per class. The rule of the upper classes are
036 * executed around the once of the lower classes.
037 * <p>
038 * For example :
039 *
040 * <pre>
041 * &#064;Rule
042 * public final TestRule rule = before(this::prepare).around(after(this::clean));
043 * </pre>
044 *
045 * This will define that the method <code>prepare</code> of the test class will
046 * be execute before each test and then, the method <code>clean</code> after
047 * each test. Of course, thanks to the lambda, it is not required to reference a
048 * method of this class, but it is also possible to pass some code directly in
049 * line (<code>()-&gt;{}</code>).
050 *
051 * @author borettim
052 * @see TestRule
053 */
054@Documented
055@Retention(RetentionPolicy.RUNTIME)
056@Target({ ElementType.FIELD })
057public @interface Rule {
058}