Skip to content
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

Added summaries settings to the UI #1509

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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 @@ -145,6 +145,10 @@ object UtTestsDialogProcessor {
UtSettings.concreteExecutionTimeoutInInstrumentedProcess = model.hangingTestsTimeout.timeoutMs
UtSettings.useCustomJavaDocTags = model.commentStyle == JavaDocCommentStyle.CUSTOM_JAVADOC_TAGS
UtSettings.enableSummariesGeneration = model.enableSummariesGeneration
UtSettings.enableTestNamesGeneration = model.enableTestNamesGeneration
UtSettings.enableDisplayNameGeneration = model.enableDisplayNameGeneration
UtSettings.enableJavaDocGeneration = model.enableJavaDocGeneration
UtSettings.enableClusterCommentsGeneration = model.enableClusterCommentsGeneration

fun now() = LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss.SSS"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class GenerateTestsModel(

var runGeneratedTestsWithCoverage : Boolean = false
var enableSummariesGeneration : Boolean = UtSettings.enableSummariesGeneration
var enableTestNamesGeneration : Boolean = UtSettings.enableTestNamesGeneration
var enableDisplayNameGeneration : Boolean = UtSettings.enableDisplayNameGeneration
var enableJavaDocGeneration : Boolean = UtSettings.enableJavaDocGeneration
var enableClusterCommentsGeneration : Boolean = UtSettings.enableClusterCommentsGeneration
}

val PsiClass.packageName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
var fuzzingValue: Double = 0.05,
var runGeneratedTestsWithCoverage: Boolean = false,
var commentStyle: JavaDocCommentStyle = JavaDocCommentStyle.defaultItem,
var enableSummariesGeneration: Boolean = UtSettings.enableSummariesGeneration
var enableSummariesGeneration: Boolean = UtSettings.enableSummariesGeneration,
var enableTestNamesGeneration: Boolean = UtSettings.enableTestNamesGeneration,
var enableDisplayNameGeneration: Boolean = UtSettings.enableDisplayNameGeneration,
var enableJavaDocGeneration: Boolean = UtSettings.enableJavaDocGeneration,
var enableClusterCommentsGeneration: Boolean = UtSettings.enableClusterCommentsGeneration
) {
constructor(model: GenerateTestsModel) : this(
codegenLanguage = model.codegenLanguage,
Expand All @@ -79,7 +83,11 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
fuzzingValue = model.fuzzingValue,
runGeneratedTestsWithCoverage = model.runGeneratedTestsWithCoverage,
commentStyle = model.commentStyle,
enableSummariesGeneration = model.enableSummariesGeneration
enableSummariesGeneration = model.enableSummariesGeneration,
enableTestNamesGeneration = model.enableTestNamesGeneration,
enableDisplayNameGeneration = model.enableDisplayNameGeneration,
enableJavaDocGeneration = model.enableJavaDocGeneration,
enableClusterCommentsGeneration = model.enableClusterCommentsGeneration
)

override fun equals(other: Any?): Boolean {
Expand All @@ -104,6 +112,10 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
if (runGeneratedTestsWithCoverage != other.runGeneratedTestsWithCoverage) return false
if (commentStyle != other.commentStyle) return false
if (enableSummariesGeneration != other.enableSummariesGeneration) return false
if (enableTestNamesGeneration != other.enableTestNamesGeneration) return false
if (enableDisplayNameGeneration != other.enableDisplayNameGeneration) return false
if (enableJavaDocGeneration != other.enableJavaDocGeneration) return false
if (enableClusterCommentsGeneration != other.enableClusterCommentsGeneration) return false

return true
}
Expand All @@ -123,6 +135,10 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
result = 31 * result + fuzzingValue.hashCode()
result = 31 * result + if (runGeneratedTestsWithCoverage) 1 else 0
result = 31 * result + if (enableSummariesGeneration) 1 else 0
result = 31 * result + if (enableTestNamesGeneration) 1 else 0
result = 31 * result + if (enableDisplayNameGeneration) 1 else 0
result = 31 * result + if (enableJavaDocGeneration) 1 else 0
result = 31 * result + if (enableClusterCommentsGeneration) 1 else 0

return result
}
Expand Down Expand Up @@ -165,8 +181,6 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
}
var runGeneratedTestsWithCoverage = state.runGeneratedTestsWithCoverage

var enableSummariesGeneration = state.enableSummariesGeneration

fun setClassesToMockAlways(classesToMockAlways: List<String>) {
state.classesToMockAlways = classesToMockAlways.distinct().toTypedArray()
}
Expand Down Expand Up @@ -202,6 +216,10 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
this.state = state
if (!state.codegenLanguage.isSummarizationCompatible()) {
this.state.enableSummariesGeneration = false
this.state.enableTestNamesGeneration = false
this.state.enableDisplayNameGeneration = false
this.state.enableJavaDocGeneration = false
this.state.enableClusterCommentsGeneration = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class SettingsWindow(val project: Project) {
private lateinit var runInspectionAfterTestGenerationCheckBox: JCheckBox
private lateinit var forceMockCheckBox: JCheckBox
private lateinit var enableSummarizationGenerationCheckBox: JCheckBox
private lateinit var enableTestNamesGenerationCheckBox: JCheckBox
private lateinit var enableDisplayNameGenerationCheckBox: JCheckBox
private lateinit var enableJavaDocGenerationCheckBox: JCheckBox
private lateinit var enableClusterCommentsGenerationCheckBox: JCheckBox

val panel: JPanel = panel {
row("Generated test language:") {
Expand All @@ -59,6 +63,10 @@ class SettingsWindow(val project: Project) {
codegenLanguageCombo.addActionListener {
if (!codegenLanguageCombo.item.isSummarizationCompatible()) {
enableSummarizationGenerationCheckBox.isSelected = false
enableTestNamesGenerationCheckBox.isSelected = false
enableJavaDocGenerationCheckBox.isSelected = false
enableDisplayNameGenerationCheckBox.isSelected = false
enableClusterCommentsGenerationCheckBox.isSelected = false
}
}
}
Expand Down Expand Up @@ -110,46 +118,115 @@ class SettingsWindow(val project: Project) {

mapOf(
RuntimeExceptionTestsBehaviour::class to RuntimeExceptionTestsBehaviour.values(),
TreatOverflowAsError::class to TreatOverflowAsError.values(),
JavaDocCommentStyle::class to JavaDocCommentStyle.values()
TreatOverflowAsError::class to TreatOverflowAsError.values()
).forEach { (loader, values) ->
valuesComboBox(loader, values)
}

row {
cell {
runInspectionAfterTestGenerationCheckBox = checkBox("Display detected errors on the Problems tool window")
enableSummarizationGenerationCheckBox = checkBox("Enable Summaries Generation")
.onApply {
settings.state.runInspectionAfterTestGeneration = runInspectionAfterTestGenerationCheckBox.isSelected
settings.state.enableSummariesGeneration = enableSummarizationGenerationCheckBox.isSelected
}
.onReset {
runInspectionAfterTestGenerationCheckBox.isSelected = settings.state.runInspectionAfterTestGeneration
enableSummarizationGenerationCheckBox.isSelected = settings.state.enableSummariesGeneration
}
.onIsModified {
runInspectionAfterTestGenerationCheckBox.isSelected xor settings.state.runInspectionAfterTestGeneration
enableSummarizationGenerationCheckBox.isSelected xor settings.state.enableSummariesGeneration
}
// .apply { ContextHelpLabel.create("Automatically run code inspection after test generation")() }
.enableIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible))
.component
}
}

row {
cell {
enableSummarizationGenerationCheckBox = checkBox("Enable Summaries Generation")
enableTestNamesGenerationCheckBox = checkBox("Enable Test Names Generation")
.onApply {
settings.state.enableSummariesGeneration = enableSummarizationGenerationCheckBox.isSelected
settings.state.enableTestNamesGeneration = enableTestNamesGenerationCheckBox.isSelected
}
.onReset {
enableSummarizationGenerationCheckBox.isSelected = settings.state.enableSummariesGeneration
enableTestNamesGenerationCheckBox.isSelected = settings.state.enableTestNamesGeneration
}
.onIsModified {
enableSummarizationGenerationCheckBox.isSelected xor settings.state.enableSummariesGeneration
enableTestNamesGenerationCheckBox.isSelected xor settings.state.enableTestNamesGeneration
}
.enableIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible))
.component
}
}

row {
cell {
enableDisplayNameGenerationCheckBox = checkBox("Enable Display Names Generation")
.onApply {
settings.state.enableDisplayNameGeneration = enableDisplayNameGenerationCheckBox.isSelected
}
.onReset {
enableDisplayNameGenerationCheckBox.isSelected = settings.state.enableDisplayNameGeneration
}
.onIsModified {
enableDisplayNameGenerationCheckBox.isSelected xor settings.state.enableDisplayNameGeneration
}
.enableIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible))
.component
}
}

row {
cell {
enableJavaDocGenerationCheckBox = checkBox("Enable Javadoc Generation")
.onApply {
settings.state.enableJavaDocGeneration = enableJavaDocGenerationCheckBox.isSelected
}
.onReset {
enableJavaDocGenerationCheckBox.isSelected = settings.state.enableJavaDocGeneration
}
.onIsModified {
enableJavaDocGenerationCheckBox.isSelected xor settings.state.enableJavaDocGeneration
}
.enableIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible))
.component
}
}

row {
cell {
enableClusterCommentsGenerationCheckBox = checkBox("Enable Cluster Comments Generation")
.onApply {
settings.state.enableClusterCommentsGeneration = enableClusterCommentsGenerationCheckBox.isSelected
}
.onReset {
enableClusterCommentsGenerationCheckBox.isSelected = settings.state.enableClusterCommentsGeneration
}
.onIsModified {
enableClusterCommentsGenerationCheckBox.isSelected xor settings.state.enableClusterCommentsGeneration
}
.enableIf(codegenLanguageCombo.selectedValueMatches(CodegenLanguage?::isSummarizationCompatible))
.component
}
}

valuesComboBox(JavaDocCommentStyle::class, JavaDocCommentStyle.values())

row {
cell {
runInspectionAfterTestGenerationCheckBox = checkBox("Display detected errors on the Problems tool window")
.onApply {
settings.state.runInspectionAfterTestGeneration = runInspectionAfterTestGenerationCheckBox.isSelected
}
.onReset {
runInspectionAfterTestGenerationCheckBox.isSelected = settings.state.runInspectionAfterTestGeneration
}
.onIsModified {
runInspectionAfterTestGenerationCheckBox.isSelected xor settings.state.runInspectionAfterTestGeneration
}
// .apply { ContextHelpLabel.create("Automatically run code inspection after test generation")() }
.component
}
}

row {
cell {
forceMockCheckBox = checkBox("Force mocking static methods")
Expand Down Expand Up @@ -178,8 +255,6 @@ class SettingsWindow(val project: Project) {
}
.onIsModified { excludeTable.isModified() }
forceMockCheckBox.addActionListener { updater.run() }


}

val fuzzLabel = JBLabel("Fuzzing")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
model.fuzzingValue = fuzzingValue
model.commentStyle = javaDocCommentStyle
model.enableSummariesGeneration = state.enableSummariesGeneration
model.enableTestNamesGeneration = state.enableTestNamesGeneration
model.enableDisplayNameGeneration = state.enableDisplayNameGeneration
model.enableJavaDocGeneration = state.enableJavaDocGeneration
model.enableClusterCommentsGeneration = state.enableClusterCommentsGeneration
UtSettings.treatOverflowAsError = treatOverflowAsError == TreatOverflowAsError.AS_ERROR
}

Expand Down