diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt index b7f39e6d54..3ac4328072 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt @@ -1154,12 +1154,12 @@ enum class MockStrategyApi( NO_MOCKS("No mocks", "Do not mock", "Do not use mock frameworks at all"), OTHER_PACKAGES( "Other packages: Mockito", - "Mock package environment", + "Mock everything outside the package", "Mock all classes outside the current package except system ones" ), OTHER_CLASSES( "Other classes: Mockito", - "Mock class environment", + "Mock everything outside the class", "Mock all classes outside the class under test except system ones" ); diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/Domain.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/Domain.kt index 804110c846..b57d9e0cd9 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/Domain.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/Domain.kt @@ -380,9 +380,9 @@ object TestNg : TestFramework(id = "TestNG",displayName = "TestNG") { """.trimIndent() } -object Junit4 : TestFramework(id = "JUnit4",displayName = "JUnit4") { +object Junit4 : TestFramework(id = "JUnit4",displayName = "JUnit 4") { private val parametrizedTestsNotSupportedError: Nothing - get() = error("Parametrized tests are not supported for JUnit4") + get() = error("Parametrized tests are not supported for JUnit 4") override val mainPackage: String = JUNIT4_PACKAGE override val testAnnotation = "@$mainPackage.Test" @@ -453,7 +453,7 @@ object Junit4 : TestFramework(id = "JUnit4",displayName = "JUnit4") { } } -object Junit5 : TestFramework(id = "JUnit5", displayName = "JUnit5") { +object Junit5 : TestFramework(id = "JUnit5", displayName = "JUnit 5") { override val mainPackage: String = JUNIT5_PACKAGE override val testAnnotation = "@$mainPackage.Test" override val testAnnotationFqn: String = "$mainPackage.Test" diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt index fa37288242..52649656e2 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt @@ -80,11 +80,11 @@ class SettingsWindow(val project: Project) { step = 50, ) - label("milliseconds") + label("milliseconds per method") .apply { ContextHelpLabel.create( - "Test generation may hang due to infinite loops or other code conditions. " + - "Set timeout to stop waiting for hanging process." + "Set this timeout to define which test is \"hanging\". Increase it to test the " + + "time-consuming method or decrease if the execution speed is critical for you." )() } } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt index 7deea934ea..5bc6a1b6b4 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt @@ -74,6 +74,7 @@ import com.intellij.util.ui.UIUtil import com.intellij.util.ui.components.BorderLayoutPanel import java.awt.BorderLayout import java.awt.Color +import java.awt.Dimension import java.awt.event.ActionEvent import java.nio.file.Files import java.nio.file.Path @@ -90,6 +91,8 @@ import javax.swing.JComboBox import javax.swing.JComponent import javax.swing.JList import javax.swing.JPanel +import javax.swing.JSpinner +import javax.swing.text.DefaultFormatter import kotlin.streams.toList import org.jetbrains.concurrency.Promise import org.jetbrains.concurrency.thenRun @@ -179,8 +182,16 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m MINIMUM_TIMEOUT_VALUE_IN_SECONDS, Int.MAX_VALUE, MINIMUM_TIMEOUT_VALUE_IN_SECONDS - ) - private val parametrizedTestSources = JCheckBox("Parametrized tests") + ).also { + when(val editor = it.editor) { + is JSpinner.DefaultEditor -> { + when(val formatter = editor.textField.formatter) { + is DefaultFormatter -> {formatter.allowsInvalid = false} + } + } + } + } + private val parametrizedTestSources = JCheckBox("Parameterized tests") private lateinit var panel: DialogPanel @@ -193,7 +204,16 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m ) private fun createComboBox(values: Array) : ComboBox { - return ComboBox(DefaultComboBoxModel(values)).also { + val comboBox = object:ComboBox(DefaultComboBoxModel(values)) { + var maxWidth = 0 + //Don't shrink strategy + override fun getPreferredSize(): Dimension { + val size = super.getPreferredSize() + if (size.width > maxWidth) maxWidth = size.width + return size.apply { width = maxWidth } + } + } + return comboBox.also { it.renderer = CodeGenerationSettingItemRenderer() } } @@ -243,7 +263,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m @Suppress("UNCHECKED_CAST") override fun createCenterPanel(): JComponent { panel = panel { - row("Test source root:") { + row("Test sources root:") { component(testSourceFolderField) } row("Testing framework:") { @@ -253,25 +273,21 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m ) } row { component(parametrizedTestSources) } - row("Mock strategy:") { + row("Mocking strategy:") { makePanelWithHelpTooltip( mockStrategies, - ContextHelpLabel.create("Mock everything around the target class or the whole package except the system classes. Otherwise mock nothing.") + ContextHelpLabel.create("Mock everything around the target class or the whole package except the system classes. " + + "Otherwise, mock nothing. Mockito will be installed, if you don't have one.") ) } row { component(staticsMocking)} row("Test generation timeout:") { - cell{ + cell { component(timeoutSpinner) label("seconds per class") + component(ContextHelpLabel.create("Set the timeout for all test generation processes per class to complete.")) } } - row { - component(cbSpecifyTestPackage) - }.apply { visible = false } - row("Destination package:") { - component(testPackageField) - }.apply { visible = false } row("Generate tests for:") {} row { @@ -380,7 +396,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m srcClasses.flatMap { it.extractFirstLevelMembers(false) } } else { srcClasses.map { MemberInfo(it) } - } + }.toSortedSet { o1, o2 -> o1.displayName.compareTo(o2.displayName, true) } checkMembers(items) membersTable.setMemberInfos(items) @@ -392,7 +408,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m membersTable.preferredScrollableViewportSize = size(-1, height) } - private fun checkMembers(allMembers: List) { + private fun checkMembers(allMembers: Collection) { val selectedDisplayNames = model.selectedMembers.map { it.displayName } val selectedMembers = allMembers.filter { it.displayName in selectedDisplayNames }