Skip to content

SONARJAVA-5291 Modify rule S7177: specify spring context #4623

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

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rules/S7177/java/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
== Why is this an issue?

The `@DirtiesContext` annotation marks the ApplicationContext as dirty and indicates that it should be cleared and recreated.
In a Spring application, the `@DirtiesContext` annotation marks the ApplicationContext as dirty and indicates that it should be cleared and recreated.
This is important in tests that modify the context, such as altering the state of singleton beans or databases.

Misconfiguring `@DirtiesContext` by setting the `methodMode` at the class level or the `classMode` at the method level will make the annotation have no effect.
Expand Down Expand Up @@ -39,4 +39,4 @@ public class TestClass {

=== Documentation

* Spring documentation - https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/annotation/DirtiesContext.html[@DirtiesContext]
* Spring documentation - https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/annotation/DirtiesContext.html[@DirtiesContext]
Loading