Skip to content

Correct the conditions when parametrization is enabled #1221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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