Annotation Interface WithJenkins


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented @ExtendWith(org.jvnet.hudson.test.junit.jupiter.JenkinsExtension.class) public @interface WithJenkins
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.

 @WithJenkins
 class ExampleJUnit5Test {

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

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

Annotating a method limits access to the method.

 class ExampleJUnit5Test {

     @WithJenkins
     @Test
     public void example(JenkinsRule r) {
         // use 'r' ...
     }
 }
 
See Also:
  • JenkinsExtension
  • ExtendWith