Skip to content

Commit

Permalink
SONARJAVA-5291 Modify rule S7177: specify spring context
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardo-pilastri-sonarsource committed Jan 28, 2025
1 parent 1e62d9f commit 7fe9688
Showing 1 changed file with 2 additions and 2 deletions.
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]

0 comments on commit 7fe9688

Please sign in to comment.