Skip to content

Commit 4f9cc2e

Browse files
authored
Improve plugin behavior classes/packages with no methods #516 (#533)
1 parent 3d91def commit 4f9cc2e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.intellij.openapi.progress.ProgressIndicator
1313
import com.intellij.openapi.progress.Task
1414
import com.intellij.openapi.project.Project
1515
import com.intellij.openapi.roots.OrderEnumerator
16+
import com.intellij.openapi.ui.Messages
1617
import com.intellij.openapi.util.text.StringUtil
1718
import com.intellij.psi.PsiClass
1819
import com.intellij.refactoring.util.classMembers.MemberInfo
@@ -215,6 +216,16 @@ object UtTestsDialogProcessor {
215216
processedClasses++
216217
}
217218

219+
if (processedClasses == 0) {
220+
invokeLater {
221+
Messages.showInfoMessage(
222+
model.project,
223+
"No methods for test generation were found among selected items",
224+
"No methods found")
225+
}
226+
return
227+
}
228+
218229
indicator.fraction = indicator.fraction.coerceAtLeast(0.9)
219230
indicator.text = "Generate code for tests"
220231
// Commented out to generate tests for collected executions even if action was canceled.

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GenerateTestsAction : AnAction() {
5454
val matchingRoot = ModuleRootManager.getInstance(module).contentEntries
5555
.flatMap { entry -> entry.sourceFolders.toList() }
5656
.singleOrNull { folder -> folder.file == srcSourceRoot }
57-
if (matchingRoot == null || matchingRoot.rootType.isForTests) {
57+
if (srcMethods.isEmpty() || matchingRoot == null || matchingRoot.rootType.isForTests) {
5858
return null
5959
}
6060

0 commit comments

Comments
 (0)