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' ...
}
}
Parameterized tests need to accept JenkinsRule parameter in a
BeforeEach or
BeforeAll annotated method.
@WithJenkins
class ExampleJUnit5Test {
private JenkinsRule r;
@BeforeEach
public void setUp(JenkinsRule r) {
this.r = r;
}
@ParameterizedTest
@ValueSource(strings = { "one", "two", "three" })
public void example(String param) {
// use 'r' ...
}
}
- See Also:
-
JenkinsExtensionExtendWith