diff --git a/src/main/kotlin/org/jetbrains/research/testspark/display/generatedTests/GeneratedTestsTabBuilder.kt b/src/main/kotlin/org/jetbrains/research/testspark/display/generatedTests/GeneratedTestsTabBuilder.kt index 514430596..d3861f123 100644 --- a/src/main/kotlin/org/jetbrains/research/testspark/display/generatedTests/GeneratedTestsTabBuilder.kt +++ b/src/main/kotlin/org/jetbrains/research/testspark/display/generatedTests/GeneratedTestsTabBuilder.kt @@ -199,10 +199,10 @@ class GeneratedTestsTabBuilder( .map { generatedTestsTabData.testCaseNameToEditorTextField[it]!! } .map { it.document.text } - displayUtils!!.applyTests(project, uiContext, testCaseComponents) + val applyingResult = displayUtils!!.applyTests(project, uiContext, testCaseComponents) // Remove the selected test cases from the cache and the tool window UI - clear() + if (applyingResult) clear() } /** diff --git a/src/main/kotlin/org/jetbrains/research/testspark/display/utils/java/JavaDisplayUtils.kt b/src/main/kotlin/org/jetbrains/research/testspark/display/utils/java/JavaDisplayUtils.kt index 7d5043747..0320308d7 100644 --- a/src/main/kotlin/org/jetbrains/research/testspark/display/utils/java/JavaDisplayUtils.kt +++ b/src/main/kotlin/org/jetbrains/research/testspark/display/utils/java/JavaDisplayUtils.kt @@ -30,7 +30,7 @@ import java.util.Locale import javax.swing.JOptionPane class JavaDisplayUtils : DisplayUtils { - override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List) { + override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List): Boolean { // Descriptor for choosing folders and java files val descriptor = FileChooserDescriptor(true, true, false, false, false, false) @@ -61,7 +61,7 @@ class JavaDisplayUtils : DisplayUtils { /** * Cancel button pressed */ - if (fileChooser.isEmpty()) return + if (fileChooser.isEmpty()) return false /** * Chosen files by user @@ -102,7 +102,7 @@ class JavaDisplayUtils : DisplayUtils { ) // Cancel button pressed - jOptionPane ?: return + jOptionPane ?: return false // Get class name from user className = jOptionPane as String @@ -158,6 +158,8 @@ class JavaDisplayUtils : DisplayUtils { OpenFileDescriptor(project, virtualFile!!), true, ) + + return true } override fun appendTestsToClass( diff --git a/src/main/kotlin/org/jetbrains/research/testspark/display/utils/kotlin/KotlinDisplayUtils.kt b/src/main/kotlin/org/jetbrains/research/testspark/display/utils/kotlin/KotlinDisplayUtils.kt index 9847d5c4a..f2d61231a 100644 --- a/src/main/kotlin/org/jetbrains/research/testspark/display/utils/kotlin/KotlinDisplayUtils.kt +++ b/src/main/kotlin/org/jetbrains/research/testspark/display/utils/kotlin/KotlinDisplayUtils.kt @@ -32,7 +32,7 @@ import java.util.Locale import javax.swing.JOptionPane class KotlinDisplayUtils : DisplayUtils { - override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List) { + override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List): Boolean { val descriptor = FileChooserDescriptor(true, true, false, false, false, false) // Apply filter with folders and java files with main class @@ -62,7 +62,7 @@ class KotlinDisplayUtils : DisplayUtils { /** * Cancel button pressed */ - if (fileChooser.isEmpty()) return + if (fileChooser.isEmpty()) return false /** * Chosen files by user @@ -103,7 +103,7 @@ class KotlinDisplayUtils : DisplayUtils { ) // Cancel button pressed - jOptionPane ?: return + jOptionPane ?: return false // Get class name from user className = jOptionPane as String @@ -167,6 +167,8 @@ class KotlinDisplayUtils : DisplayUtils { OpenFileDescriptor(project, virtualFile!!), true, ) + + return true } override fun appendTestsToClass( diff --git a/src/main/kotlin/org/jetbrains/research/testspark/display/utils/template/DisplayUtils.kt b/src/main/kotlin/org/jetbrains/research/testspark/display/utils/template/DisplayUtils.kt index 89ea668b6..5beb63a73 100644 --- a/src/main/kotlin/org/jetbrains/research/testspark/display/utils/template/DisplayUtils.kt +++ b/src/main/kotlin/org/jetbrains/research/testspark/display/utils/template/DisplayUtils.kt @@ -12,8 +12,10 @@ import org.jetbrains.research.testspark.langwrappers.PsiClassWrapper interface DisplayUtils { /** * Applies specified tests to a given project. + * + * @returns true, if tests applying is successful, otherwise false */ - fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List) + fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List): Boolean /** * Appends specified tests to a class within the given project.