Skip to content

Commit dbeaf15

Browse files
committed
Add usvm engine option on UI
1 parent c7f2ac4 commit dbeaf15

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/Domain.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,30 @@ enum class ParametrizedTestSource(
691691
}
692692
}
693693

694+
enum class SymbolicEngineSource(
695+
override val id: String,
696+
override val displayName: String,
697+
override val description: String = "Use $displayName symbolic engine"
698+
) : CodeGenerationSettingItem {
699+
UnitTestBot(
700+
id = "UnitTestBot",
701+
displayName = "UnitTestBot",
702+
description = "Use UnitTestBot symbolic engine",
703+
),
704+
Usvm(
705+
id = "USVM",
706+
displayName = "USVM",
707+
description = "Use USVM symbolic engine",
708+
);
709+
710+
override fun toString(): String = id
711+
712+
companion object : CodeGenerationSettingBox {
713+
override val defaultItem: SymbolicEngineSource = SymbolicEngineSource.UnitTestBot
714+
override val allItems: List<SymbolicEngineSource> = SymbolicEngineSource.values().toList()
715+
}
716+
}
717+
694718
enum class ProjectType {
695719
/**
696720
* Standard JVM project without DI frameworks

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.KtFile
2626
import org.utbot.common.PathUtil.fileExtension
2727
import org.utbot.framework.SummariesGenerationType
2828
import org.utbot.framework.UtSettings
29+
import org.utbot.framework.codegen.domain.SymbolicEngineSource
2930
import org.utbot.framework.plugin.api.ClassId
3031
import org.utbot.framework.plugin.api.MockFramework
3132
import org.utbot.framework.plugin.api.MockStrategyApi
@@ -77,6 +78,7 @@ class GenerateTestsModel(
7778
lateinit var mockFramework: MockFramework
7879
lateinit var staticsMocking: StaticsMocking
7980
lateinit var parametrizedTestSource: ParametrizedTestSource
81+
lateinit var symbolicEngineSource: SymbolicEngineSource
8082
lateinit var runtimeExceptionTestsBehaviour: RuntimeExceptionTestsBehaviour
8183
lateinit var hangingTestsTimeout: HangingTestsTimeout
8284
var useTaintAnalysis: Boolean = false

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import org.utbot.framework.codegen.domain.ParametrizedTestSource
8888
import org.utbot.framework.codegen.domain.ProjectType
8989
import org.utbot.framework.codegen.domain.SpringModule.*
9090
import org.utbot.framework.codegen.domain.StaticsMocking
91+
import org.utbot.framework.codegen.domain.SymbolicEngineSource
9192
import org.utbot.framework.codegen.domain.TestFramework
9293
import org.utbot.framework.codegen.domain.TestNg
9394
import org.utbot.framework.plugin.api.MockStrategyApi
@@ -215,6 +216,8 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
215216
}
216217
private val parametrizedTestSources = JCheckBox("Parameterized tests")
217218

219+
private val useExperimentalEngine = JCheckBox("Experimental symbolic engine")
220+
218221
private lateinit var panel: DialogPanel
219222

220223
@Suppress("UNCHECKED_CAST")
@@ -412,6 +415,13 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
412415
cell(testFrameworks)
413416
}
414417

418+
row {
419+
cell(useExperimentalEngine)
420+
contextHelp("USVM symbolic engine will be used")
421+
}.enabledIf(ComboBoxPredicate(springConfig) {
422+
model.projectType == ProjectType.PureJvm
423+
})
424+
415425
if (model.projectType == ProjectType.Spring) {
416426
row("Spring configuration:") {
417427
cell(springConfig)
@@ -705,6 +715,8 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
705715
model.mockStrategy = mockStrategies.item
706716
model.parametrizedTestSource =
707717
if (parametrizedTestSources.isSelected) ParametrizedTestSource.PARAMETRIZE else ParametrizedTestSource.DO_NOT_PARAMETRIZE
718+
model.symbolicEngineSource =
719+
if (useExperimentalEngine.isSelected) SymbolicEngineSource.Usvm else SymbolicEngineSource.UnitTestBot
708720

709721
model.mockFramework = MOCKITO
710722
model.staticsMocking = if (staticsMocking.isSelected) MockitoStaticMocking else NoStaticMocking
@@ -903,6 +915,9 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
903915
parametrizedTestSources.isSelected = (settings.parametrizedTestSource == ParametrizedTestSource.PARAMETRIZE
904916
&& model.projectType == ProjectType.PureJvm)
905917

918+
useExperimentalEngine.isSelected = (settings.symbolicEngineSource == SymbolicEngineSource.Usvm
919+
&& model.projectType == ProjectType.PureJvm)
920+
906921
codegenLanguages.item = model.codegenLanguage
907922

908923
val installedTestFramework = TestFramework.allItems.singleOrNull { it.isInstalled }
@@ -1212,6 +1227,18 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
12121227
updateControlsEnabledStatus()
12131228
}
12141229

1230+
useExperimentalEngine.addActionListener {_ ->
1231+
if (useExperimentalEngine.isSelected) {
1232+
mockStrategies.isEnabled = false
1233+
mockStrategies.item = MockStrategyApi.NO_MOCKS
1234+
1235+
staticsMocking.isEnabled = false
1236+
staticsMocking.isSelected = false
1237+
} else {
1238+
updateControlsEnabledStatus()
1239+
}
1240+
}
1241+
12151242
springTestType.addActionListener { event ->
12161243
val comboBox = event.source as ComboBox<*>
12171244
val item = comboBox.item as SpringTestType
@@ -1382,7 +1409,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m
13821409
}
13831410

13841411
private fun updateControlsEnabledStatus() {
1385-
mockStrategies.isEnabled = true
1412+
mockStrategies.isEnabled = !useExperimentalEngine.isSelected
13861413

13871414
updateParametrizationEnabled()
13881415
updateStaticMockEnabled()

utbot-ui-commons/src/main/kotlin/org/utbot/intellij/plugin/settings/CommonSettings.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import java.util.concurrent.CompletableFuture
3737
import kotlin.reflect.KClass
3838
import org.utbot.common.isWindows
3939
import org.utbot.framework.SummariesGenerationType
40+
import org.utbot.framework.codegen.domain.SymbolicEngineSource
4041
import org.utbot.framework.codegen.domain.UnknownTestFramework
4142
import org.utbot.framework.plugin.api.SpringTestType
4243
import org.utbot.framework.plugin.api.isSummarizationCompatible
@@ -66,6 +67,7 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
6667
var forceStaticMocking: ForceStaticMocking = ForceStaticMocking.defaultItem,
6768
var treatOverflowAsError: TreatOverflowAsError = TreatOverflowAsError.defaultItem,
6869
var parametrizedTestSource: ParametrizedTestSource = ParametrizedTestSource.defaultItem,
70+
var symbolicEngineSource: SymbolicEngineSource = SymbolicEngineSource.defaultItem,
6971
var classesToMockAlways: Array<String> = Mocker.defaultSuperClassesToMockAlwaysNames.toTypedArray(),
7072
var springTestType: SpringTestType = SpringTestType.defaultItem,
7173
var springConfig: String = SpringConfig.defaultItem,
@@ -98,6 +100,7 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
98100
if (forceStaticMocking != other.forceStaticMocking) return false
99101
if (treatOverflowAsError != other.treatOverflowAsError) return false
100102
if (parametrizedTestSource != other.parametrizedTestSource) return false
103+
if (symbolicEngineSource != other.symbolicEngineSource) return false
101104
if (!classesToMockAlways.contentEquals(other.classesToMockAlways)) return false
102105
if (springTestType != other.springTestType) return false
103106
if (springConfig != other.springConfig) return false
@@ -124,6 +127,7 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
124127
result = 31 * result + forceStaticMocking.hashCode()
125128
result = 31 * result + treatOverflowAsError.hashCode()
126129
result = 31 * result + parametrizedTestSource.hashCode()
130+
result = 31 * result + symbolicEngineSource.hashCode()
127131
result = 31 * result + classesToMockAlways.contentHashCode()
128132
result = 31 * result + springTestType.hashCode()
129133
result = 31 * result + springConfig.hashCode()
@@ -174,6 +178,8 @@ class Settings(val project: Project) : PersistentStateComponent<Settings.State>
174178

175179
val parametrizedTestSource: ParametrizedTestSource get() = state.parametrizedTestSource
176180

181+
val symbolicEngineSource: SymbolicEngineSource get() = state.symbolicEngineSource
182+
177183
val classesToMockAlways: Set<String> get() = state.classesToMockAlways.toSet()
178184

179185
val springTestType: SpringTestType get() = state.springTestType

0 commit comments

Comments
 (0)