Package io.codemodder.testutils
Annotation Interface Metadata
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends io.codemodder.CodeChanger>
The codemod being tested.String[]
The GAV coordinates of any dependencies that should be added to the project after the codemod's execution.The classpath-based test directory containing the test case artifacts. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean
Whether to re-run the transformed code through a second transformation with the same inputs, but with the transformed code, to see if another transformation is erroneously made.int[]
The expected failed fix metadata that the codemod should report.int[]
The expected fix metadata that the codemod should report.Used to filter test execution to only the tests with a display name that matches the given regex.Class<? extends io.codemodder.ProjectProvider>[]
Some codemods change their behavior based on the context of the app -- like which versions of libraries are present.Test files should always be renamed to this before execution.String[]
Sonar issues file names for testing multiple json files
-
Element Details
-
codemodType
Class<? extends io.codemodder.CodeChanger> codemodTypeThe codemod being tested. -
testResourceDir
String testResourceDirThe classpath-based test directory containing the test case artifacts. -
dependencies
String[] dependenciesThe GAV coordinates of any dependencies that should be added to the project after the codemod's execution.
-
-
-
renameTestFile
String renameTestFileTest files should always be renamed to this before execution. Helps test codemods that only target certain file names. Also supports directories in the path.- Default:
- ""
-
doRetransformTest
boolean doRetransformTestWhether to re-run the transformed code through a second transformation with the same inputs, but with the transformed code, to see if another transformation is erroneously made.- Default:
- true
-
projectProviders
Class<? extends io.codemodder.ProjectProvider>[] projectProvidersSome codemods change their behavior based on the context of the app -- like which versions of libraries are present. If you want to simulate specific contextual conditions related to dependencies, you can add a customized provider here A usage example can be found atHardenXStreamCodemodTestProjectProvider
- Default:
- {}
-
expectingFixesAtLines
int[] expectingFixesAtLinesThe expected fix metadata that the codemod should report.- Default:
- {}
-
expectingFailedFixesAtLines
int[] expectingFailedFixesAtLinesThe expected failed fix metadata that the codemod should report.- Default:
- {}
-
sonarJsonFiles
String[] sonarJsonFilesSonar issues file names for testing multiple json files- Default:
- {}
-
only
String onlyUsed to filter test execution to only the tests with a display name that matches the given regex. This is a test-driven development tool for iterating on a single, dynamic test case.@Metadata( codemodType = LogFailedLoginCodemod.class, testResourceDir = "log-failed-login", only = "\\/safe\\/.*", dependencies = {}) public final class LogFailedLoginCodemodTest implements CodemodTestMixin {
- Default:
- ""
-