Annotation Interface WithJenkinsConfiguredWithCode


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented @ExtendWith(io.jenkins.plugins.casc.misc.junit.jupiter.JenkinsConfiguredWithCodeExtension.class) public @interface WithJenkinsConfiguredWithCode
JUnit 5 meta annotation providing JenkinsRule integration.

Test methods using the rule extension need to accept it by JenkinsRule parameter; each test case gets a new rule object. An annotated method without a JenkinsRule parameter behaves as if it were not annotated.

Annotating a class provides access for all of its tests. Unrelated test cases can omit the parameter.

 @WithJenkinsConfiguredWithCode
 class ExampleJUnit5Test {

     @Test
     public void example(JenkinsConfiguredWithCodeRule r) {
         // use 'r' ...
     }

     @Test
     public void exampleNotUsingRule() {
         // ...
     }
 }
 

Annotating a method limits access to the method.

 class ExampleJUnit5Test {

     @WithJenkinsConfiguredWithCode
     @Test
     public void example(JenkinsConfiguredWithCodeRule r) {
         // use 'r' ...
     }
 }
 

Class static fields are also supported

 class ExampleJUnit5Test {

     @WithJenkinsConfiguredWithCode
     static JenkinsConfiguredWithCodeRule r;

     @Test
     public void example() {
         // use 'r' ...
     }

     @Test
     public void anotherExample() {
         // use 'r' ...
     }

 }
 
See Also:
  • JenkinsConfiguredWithCodeExtension
  • ExtendWith