Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.OrderEnumerator
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiClass
import com.intellij.refactoring.util.classMembers.MemberInfo
Expand Down Expand Up @@ -215,6 +216,16 @@ object UtTestsDialogProcessor {
processedClasses++
}

if (processedClasses == 0) {
invokeLater {
Messages.showInfoMessage(
model.project,
"No methods for test generation were found among selected items",
"No methods found")
}
return
}

Choose a reason for hiding this comment

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

Should we return here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added return


indicator.fraction = indicator.fraction.coerceAtLeast(0.9)
indicator.text = "Generate code for tests"
// Commented out to generate tests for collected executions even if action was canceled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class GenerateTestsAction : AnAction() {
val matchingRoot = ModuleRootManager.getInstance(module).contentEntries
.flatMap { entry -> entry.sourceFolders.toList() }
.singleOrNull { folder -> folder.file == srcSourceRoot }
if (matchingRoot == null || matchingRoot.rootType.isForTests) {
if (srcMethods.isEmpty() || matchingRoot == null || matchingRoot.rootType.isForTests) {
return null
}

Expand Down