File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\main\java\org\jvnet\hudson\test\TestExtension.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2010, Sun Microsystems, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package org.jvnet.hudson.test;
25
26 import hudson.Extension;
27 import net.java.sezpoz.Indexable;
28
29 import java.lang.annotation.Documented;
30 import java.lang.annotation.Retention;
31 import java.lang.annotation.Target;
32
33 import static java.lang.annotation.ElementType.*;
34 import static java.lang.annotation.RetentionPolicy.RUNTIME;
35
36 /**
37 * Works like {@link Extension} except used for inserting extensions during unit tests.
38 *
39 * <p>
40 * This annotation must be used on a method/field of a test case class, or an nested type of the test case.
41 * The extensions are activated only when the outer test class is being run.
42 *
43 * @author Kohsuke Kawaguchi
44 * @see TestExtensionLoader
45 */
46 @Indexable
47 @Retention(RUNTIME)
48 @Target({TYPE, FIELD, METHOD})
49 @Documented
50 public @interface TestExtension {
51 /**
52 * To make this extension only active for one test case, specify the test method name.
53 * Otherwise, leave it unspecified and it'll apply to all the test methods defined in the same class.
54 *
55 * <h2>Example</h2>
56 * <pre>
57 * class FooTest extends HudsonTestCase {
58 * public void test1() { ... }
59 * public void test2() { ... }
60 *
61 * // this only kicks in during test1
62 * &#64;TestExtension("test1")
63 * class Foo extends ConsoleAnnotator { ... }
64 *
65 * // this kicks in both for test1 and test2
66 * &#64;TestExtension
67 * class Bar extends ConsoleAnnotator { ... }
68 * }
69 * </pre>
70 */
71 String value() default "";
72 }
73