Skip to content

Commit

Permalink
Correct the conditions when parametrization is enabled (#1221)
Browse files Browse the repository at this point in the history
* Correct the conditions when parametrization is enabled.

* Correct descriptors for TestNg
  • Loading branch information
EgorkaKulikov authored Oct 24, 2022
1 parent 12ad92c commit 321ddd9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ 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.
*/

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")
ExternalLibraryDescriptor("org.testng", "testng", "7.5", "7.5", "7.5")
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
}

updateTestFrameworksList(settings.parametrizedTestSource)
updateParametrizationEnabled(currentFrameworkItem)
updateParametrizationEnabled()

updateMockStrategyList()

Expand Down Expand Up @@ -907,17 +907,24 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
if (!staticsMocking.isEnabled) {
staticsMocking.isSelected = false
}

updateParametrizationEnabled()
}

testFrameworks.addActionListener { event ->
val comboBox = event.source as ComboBox<*>
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 {
Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit 321ddd9

Please sign in to comment.