Skip to content
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class GenerateTestsCommand :
"-s", "--source",
help = "Specifies source code file for a generated test"
)
.required()
.check("Must exist and end with .java or .kt suffix") {
(it.endsWith(".java") || it.endsWith(".kt")) && Files.exists(Paths.get(it))
}
Expand Down Expand Up @@ -113,7 +112,7 @@ class GenerateTestsCommand :
val testSets = generateTestSets(
testCaseGenerator,
targetMethods,
Paths.get(sourceCodeFile),
sourceCodeFile?.let(Paths::get),
searchDirectory = workingDirectory,
chosenClassesToMockAlways = (Mocker.defaultSuperClassesToMockAlwaysNames + classesToMockAlways)
.mapTo(mutableSetOf()) { ClassId(it) }
Expand Down Expand Up @@ -149,9 +148,12 @@ class GenerateTestsCommand :
projectRootPath == null -> {
println("The path to the project root is required to generate a report. Please, specify \"--project-root\" option.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we should not ask specifying but suggest specifying the source code. Otherwise the user may think that it is mandatory for proper work of utility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --project-root is mandatory only when --sarif is set. In others cases it is not mandatory

}
sourceCodeFile == null -> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we need curly braces here )

println("The source file is not found. Please, specify \"--source\" option.")
}
else -> {
val sourceFinding =
SourceFindingStrategyDefault(classFqn, sourceCodeFile, testsFilePath, projectRootPath)
SourceFindingStrategyDefault(classFqn, sourceCodeFile!!, testsFilePath, projectRootPath)
val report = SarifReport(testSets, testClassBody, sourceFinding).createReport().toJson()
saveToFile(report, sarifReport)
println("The report was saved to \"$sarifReport\".")
Expand Down