Annotation Type TestExtension


@Retention(RUNTIME) @Target({TYPE,FIELD,METHOD}) @Documented public @interface TestExtension
Works like Extension except used for inserting extensions during unit tests.

This annotation must be used on a method/field of a test case class, or an nested type of the test case. The extensions are activated only when the outer test class is being run.

Author:
Kohsuke Kawaguchi
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    To make this extension only active for one test case, specify the test method name.
  • Element Details

    • value

      String[] value
      To make this extension only active for one test case, specify the test method name. Otherwise, leave it unspecified and it'll apply to all the test methods defined in the same class. For example:
       class FooTest extends HudsonTestCase {
           public void test1() { ... }
           public void test2() { ... }
      
           // this only kicks in during test1
           @TestExtension("test1")
           class Foo extends ConsoleAnnotator { ... }
      
           // this kicks in both for test1 and test2
           @TestExtension
           class Bar extends ConsoleAnnotator { ... }
      
           // You can also specify multiple test cases with parameters
           @TestExtension({"test1", "test2"})
           class Baz extends ConsoleAnnotator { ... }
       }
       
      Default:
      {}