-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mockito best practices to clear out MockitoSettings
Fixes #589
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/test/java/org/openrewrite/java/testing/mockito/RemoveMockitoSettingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.openrewrite.java.testing.mockito; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openrewrite.DocumentExample; | ||
import org.openrewrite.InMemoryExecutionContext; | ||
import org.openrewrite.java.JavaParser; | ||
import org.openrewrite.test.RecipeSpec; | ||
import org.openrewrite.test.RewriteTest; | ||
|
||
import static org.openrewrite.java.Assertions.java; | ||
|
||
class RemoveMockitoSettingsTest implements RewriteTest { | ||
|
||
@Override | ||
public void defaults(RecipeSpec spec) { | ||
spec | ||
.parser(JavaParser.fromJavaVersion() | ||
.classpathFromResources(new InMemoryExecutionContext(), | ||
"mockito-core", "mockito-junit-jupiter", "junit-jupiter-api")) | ||
.recipeFromResource("/META-INF/rewrite/mockito.yml", "org.openrewrite.java.testing.mockito.MockitoBestPractices"); | ||
} | ||
|
||
@Test | ||
@DocumentExample | ||
void removeMockitoSettings() { | ||
rewriteRun( | ||
//language=java | ||
java( | ||
""" | ||
import org.mockito.junit.jupiter.MockitoSettings; | ||
import org.mockito.quality.Strictness; | ||
@MockitoSettings(strictness = Strictness.WARN) | ||
class A {} | ||
""", | ||
""" | ||
class A {} | ||
""" | ||
) | ||
); | ||
} | ||
|
||
@Test | ||
void removeMockitoSettingsFullyQualified() { | ||
rewriteRun( | ||
//language=java | ||
java( | ||
""" | ||
import org.mockito.junit.jupiter.MockitoSettings; | ||
@MockitoSettings(strictness = org.mockito.quality.Strictness.WARN) | ||
class A {} | ||
""", | ||
""" | ||
class A {} | ||
""" | ||
) | ||
); | ||
} | ||
|
||
@Test | ||
void retainMisMatchedArgument() { | ||
rewriteRun( | ||
//language=java | ||
java( | ||
""" | ||
import org.mockito.junit.jupiter.MockitoSettings; | ||
import org.mockito.quality.Strictness; | ||
@MockitoSettings(strictness = Strictness.LENIENT) | ||
class A {} | ||
""" | ||
) | ||
); | ||
} | ||
} |