Skip to content

Improve plugin behavior classes/packages with no methods #516 #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2022
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