-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Labels
Description
What problem are you trying to solve?
Some tests were not discovered or ran, leading to broken test coverage and warnings on 5.13+
So when we detect a method declaration annotated with any of the test annotations (@Test
, @ParameterizedTest
, @RepeatedTest
, ...), which does not have void
return type:
- Change the method return type to
void
- Remove any
return
statements from the body, which are not inside a nested lambda or class
Describe the situation before applying the recipe
import org.junit.jupiter.api.Test;
class A {
@Test
int foo() {
int i = 42;
return i;
}
}
Describe the situation after applying the recipe
import org.junit.jupiter.api.Test;
class A {
@Test
void foo() {
int i = 42;
}
}
Have you considered any alternatives or workarounds?
- Add a warning comment about test discovery: Already done at test execution and in IDE.
- Remove the test annotation; perhaps safer in case the test method is called anywhere, but perhaps more unexpected.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done