From a82ec9a22d0c96c14183abe205d662da2d1bcceb Mon Sep 17 00:00:00 2001 From: Egor Kulikov Date: Mon, 24 Oct 2022 14:31:59 +0300 Subject: [PATCH 1/2] Correct the conditions when parametrization is enabled. --- .../plugin/ui/GenerateTestsDialogWindow.kt | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) 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 046ab0f273..4e1926356e 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 @@ -658,7 +658,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m } updateTestFrameworksList(settings.parametrizedTestSource) - updateParametrizationEnabled(currentFrameworkItem) + updateParametrizationEnabled() updateMockStrategyList() @@ -907,6 +907,8 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m if (!staticsMocking.isEnabled) { staticsMocking.isSelected = false } + + updateParametrizationEnabled() } testFrameworks.addActionListener { event -> @@ -914,10 +916,15 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m val item = comboBox.item as TestFramework currentFrameworkItem = item - updateParametrizationEnabled(currentFrameworkItem) + + updateParametrizationEnabled() + } + + codegenLanguages.addActionListener { _ -> + updateParametrizationEnabled() } - parametrizedTestSources.addActionListener { event -> + parametrizedTestSources.addActionListener { _ -> val parametrizedTestSource = if (parametrizedTestSources.isSelected) { ParametrizedTestSource.PARAMETRIZE } else { @@ -980,12 +987,17 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m currentFrameworkItem = testFrameworks.item } - //We would like to disable parametrization options for JUnit4 - private fun updateParametrizationEnabled(testFramework: TestFramework) { - when (testFramework) { - Junit4 -> parametrizedTestSources.isEnabled = false - Junit5, - TestNg -> parametrizedTestSources.isEnabled = true + private fun updateParametrizationEnabled() { + val languageIsSupported = codegenLanguages.item == CodegenLanguage.JAVA + val frameworkIsSupported = currentFrameworkItem == Junit5 + || currentFrameworkItem == TestNg && findSdkVersion(model.srcModule).feature > minSupportedSdkVersion + val mockStrategyIsSupported = mockStrategies.item == MockStrategyApi.NO_MOCKS + + parametrizedTestSources.isEnabled = + languageIsSupported && frameworkIsSupported && mockStrategyIsSupported + + if (!parametrizedTestSources.isEnabled) { + parametrizedTestSources.isSelected = false } } From 9ae31a4d99e605fb4f98d6fd86b37005fb72b0d3 Mon Sep 17 00:00:00 2001 From: Egor Kulikov Date: Mon, 24 Oct 2022 14:56:40 +0300 Subject: [PATCH 2/2] Correct descriptors for TestNg --- .../intellij/plugin/models/ExternalLibraryDescriptors.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/ExternalLibraryDescriptors.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/ExternalLibraryDescriptors.kt index 22a6befa87..e9f9e1bf8c 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/ExternalLibraryDescriptors.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/ExternalLibraryDescriptors.kt @@ -24,7 +24,7 @@ fun mockitoCoreLibraryDescriptor(versionInProject: String?) = /** * TestNg requires JDK 11 since version 7.6.0 - * For projects with JDK 8 version 7.5.0 should be installed. + * For projects with JDK 8 version 7.5 should be installed. * See https://groups.google.com/g/testng-users/c/BAFB1vk-kok?pli=1 for more details. */ @@ -32,4 +32,4 @@ fun testNgNewLibraryDescriptor(versionInProject: String?) = ExternalLibraryDescriptor("org.testng", "testng", "7.6.0", null, versionInProject ?: "7.6.0") fun testNgOldLibraryDescriptor() = - ExternalLibraryDescriptor("org.testng", "testng", "7.5.0", "7.5.0", "7.5.0") \ No newline at end of file + ExternalLibraryDescriptor("org.testng", "testng", "7.5", "7.5", "7.5") \ No newline at end of file