
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
62 lines
1.1 KiB
Plaintext
62 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Annotating unit tests with more than one test-related annotation is not only useless but could also result in unexpected behavior like failing tests or unwanted side-effects.
|
|
|
|
|
|
|
|
This rule reports an issue when a test method is annotated with more than one of the following competing annotation:
|
|
|
|
* @Test
|
|
* @RepeatedTest
|
|
* @ParameterizedTest
|
|
* @TestFactory
|
|
* @TestTemplate
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,java]
|
|
----
|
|
@Test
|
|
@RepeatedTest(2) // Noncompliant, this test will be repeated 3 times
|
|
void test() { }
|
|
|
|
@ParameterizedTest
|
|
@Test
|
|
@MethodSource("methodSource")
|
|
void test2(int argument) { } // Noncompliant, this test will fail with ParameterResolutionException
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,java]
|
|
----
|
|
@RepeatedTest(2)
|
|
void test() { }
|
|
|
|
@ParameterizedTest
|
|
@MethodSource("methodSource")
|
|
void test2(int argument) { }
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove one of these conflicting annotations.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
Primary location: method name
|
|
|
|
Secondaries: test annotations
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|