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

Treat unit test setup methods as constructors for UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR #453

Closed
ThrawnCA opened this issue Oct 16, 2017 · 3 comments · Fixed by #2872
Closed

Comments

@ThrawnCA
Copy link
Contributor

JUnit and TestNG test classes typically initialise their fields within a setup method, rather than the constructor, which often results in UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR. Can appropriately-annotated setup methods (@Before, @BeforeMethod, @BeforeClass) be treated as constructors for this purpose?

@rscarvalho
Copy link

any updates on this?

@jansohn
Copy link

jansohn commented Dec 14, 2023

We also start seeing this with JUnit 5 and its annotation @BeforeEach

@hazendaz
Copy link
Member

Would need @BeforeAll as well.

gtoison added a commit to gtoison/spotbugs that referenced this issue Feb 22, 2024
hazendaz pushed a commit that referenced this issue Feb 24, 2024
…IALIZED_IN_CONSTRUCTOR` (#2872)

* test: reproducer for issue #453

* fix: consider annotations when looking for initializer methods

* fix: typo, added reference to issues

* fix: moved the annotations list into a constant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants