Skip to content

Forbid return values from test and lifecycle methods #835

@sbrannen

Description

@sbrannen

Status Quo

In the JUnit Jupiter programming model it is currently not forbidden for @Test and lifecycle methods (i.e., @BeforeEach, @BeforeAll, etc.) to have a return value, even if it's assumed that no one declares anything other than void as a return type for such methods.

For example, the following currently execute.

@Test
int test() {
	fail("Boom!");
	return 42;
}
@BeforeEach
int before() {
	fail("Boom!");
	return 42;
}

Related Issues

Deliverables

  • Forbid return values from test and lifecycle methods via test predicates that exclude such methods.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions