Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trick to make spotBugs find missing assertions when using SoftAssertions ? #3244

Open
vincent-fuchs opened this issue Oct 30, 2023 · 1 comment
Labels
theme: soft assertions An issue related to the soft assertions

Comments

@vincent-fuchs
Copy link

Feature summary

Spotbugs (4.7.3.6) correctly identifies missing assertions, as documented in https://assertj.github.io/doc/#forgetting-to-call-an-assertion

Is there a way to have the same behavior when using SoftAssertions ?

Example

@ExtendWith(SoftAssertionsExtension.class)
public class TmpTest {
	@InjectSoftAssertions
	protected SoftAssertions softly;

	@Test
	void demoTest() {

		List aList = List.of("a", "b");

		// correctly detected by Spotbugs
		assertThat(aList.contains("a"));

		// incorrectly detected by Spotbugs
		softly.assertThat(aList.contains("a"));
	}
}
@scordio
Copy link
Member

scordio commented Oct 30, 2023

Could this be caused by the fact that @CheckReturnValue is currently applied to StandardSoftAssertionsProvider but it's not annotated as @Inherited?

@scordio scordio added the theme: soft assertions An issue related to the soft assertions label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: soft assertions An issue related to the soft assertions
Projects
None yet
Development

No branches or pull requests

2 participants