Skip to content

Persist Test Generation Timeout in utbot-settings.xml #1950

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
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 @@ -109,7 +109,7 @@ object UtTestsDialogProcessor {
srcClasses,
extractMembersFromSrcClasses,
focusedMethods,
UtSettings.utBotGenerationTimeoutInMillis,
project.service<Settings>().generationTimeoutInMillis
)
if (model.getAllTestSourceRoots().isEmpty() && project.isBuildWithGradle) {
val errorMessage = """
Expand Down Expand Up @@ -308,7 +308,7 @@ object UtTestsDialogProcessor {
Messages.showInfoMessage(
model.project,
"No methods for test generation were found among selected items",
"No methods found"
"No Methods Found"
)
}
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private fun fromGenerateTestsModel(model: GenerateTestsModel): Settings.State {
fuzzingValue = model.fuzzingValue,
runGeneratedTestsWithCoverage = model.runGeneratedTestsWithCoverage,
commentStyle = model.commentStyle,
generationTimeoutInMillis = model.timeout,
summariesGenerationType = model.summariesGenerationType
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ private const val RECENTS_KEY = "org.utbot.recents"
private const val SAME_PACKAGE_LABEL = "same as for sources"

private const val WILL_BE_INSTALLED_LABEL = " (will be installed)"
private const val WILL_BE_CONFIGURED_LABEL = " (will be configured)"
private const val MINIMUM_TIMEOUT_VALUE_IN_SECONDS = 1

private const val ACTION_GENERATE = "Generate Tests"
private const val ACTION_GENERATE_AND_RUN = "Generate and Run"
Expand All @@ -174,7 +172,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
findTestPackageComboValue(),
model.project,
RECENTS_KEY,
"Choose destination package"
"Choose Destination Package"
)

private val testSourceFolderField = TestFolderComboWithBrowseButton(model)
Expand All @@ -184,12 +182,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
private val mockStrategies = createComboBox(MockStrategyApi.values())
private val staticsMocking = JCheckBox("Mock static methods")
private val timeoutSpinner =
JBIntSpinner(
TimeUnit.MILLISECONDS.toSeconds(UtSettings.utBotGenerationTimeoutInMillis).toInt(),
MINIMUM_TIMEOUT_VALUE_IN_SECONDS,
Int.MAX_VALUE,
MINIMUM_TIMEOUT_VALUE_IN_SECONDS
).also {
JBIntSpinner(TimeUnit.MILLISECONDS.toSeconds(model.timeout).toInt(), 1, Int.MAX_VALUE, 1).also {
when(val editor = it.editor) {
is JSpinner.DefaultEditor -> {
when(val formatter = editor.textField.formatter) {
Expand Down Expand Up @@ -617,7 +610,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
private fun showTestRootAbsenceErrorMessage() =
Messages.showErrorDialog(
"Test source root is not configured or is located out of content entry!",
"Generation error"
"Generation Error"
)

private fun getOrCreateTestRoot(testSourceRoot: VirtualFile): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
var runGeneratedTestsWithCoverage: Boolean = false,
var commentStyle: JavaDocCommentStyle = JavaDocCommentStyle.defaultItem,
var summariesGenerationType: SummariesGenerationType = UtSettings.summaryGenerationType,
var generationTimeoutInMillis: Long = UtSettings.utBotGenerationTimeoutInMillis,
var enableExperimentalLanguagesSupport: Boolean = false,
) {

Expand All @@ -90,6 +91,7 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
if (runGeneratedTestsWithCoverage != other.runGeneratedTestsWithCoverage) return false
if (commentStyle != other.commentStyle) return false
if (summariesGenerationType != other.summariesGenerationType) return false
if (generationTimeoutInMillis != other.generationTimeoutInMillis) return false

return true
}
Expand All @@ -110,6 +112,7 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
result = 31 * result + fuzzingValue.hashCode()
result = 31 * result + if (runGeneratedTestsWithCoverage) 1 else 0
result = 31 * result + summariesGenerationType.hashCode()
result = 31 * result + generationTimeoutInMillis.hashCode()

return result
}
Expand All @@ -132,6 +135,12 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
state.hangingTestsTimeout = value
}

var generationTimeoutInMillis : Long
get() = state.generationTimeoutInMillis
set(value) {
state.generationTimeoutInMillis = value
}

val staticsMocking: StaticsMocking get() = state.staticsMocking

val runInspectionAfterTestGeneration: Boolean get() = state.runInspectionAfterTestGeneration
Expand Down