Skip to content

Commit e71b284

Browse files
Fix wrong mocking configuration #1936 (#1942)
1 parent 83eab40 commit e71b284

File tree

1 file changed

+16
-3
lines changed
  • utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api

1 file changed

+16
-3
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt

+16-3
Original file line numberDiff line numberDiff line change
@@ -1156,11 +1156,24 @@ class WildcardTypeParameter : TypeParameters(emptyList())
11561156
*/
11571157
open class StandardApplicationContext(
11581158
val mockFrameworkInstalled: Boolean = true,
1159-
val staticsMockingIsConfigured: Boolean = true,
1159+
staticsMockingIsConfigured: Boolean = true,
11601160
) {
1161+
var staticsMockingIsConfigured = staticsMockingIsConfigured
1162+
private set
1163+
11611164
init {
1162-
if (!mockFrameworkInstalled) {
1163-
require(!staticsMockingIsConfigured) { "Static mocking cannot be used without mock framework" }
1165+
/**
1166+
* Situation when mock framework is not installed but static mocking is configured is semantically incorrect.
1167+
*
1168+
* However, it may be obtained in real application after this actions:
1169+
* - fully configure mocking (dependency installed + resource file created)
1170+
* - remove mockito-core dependency from project
1171+
* - forget to remove mock-maker file from resource directory
1172+
*
1173+
* Here we transform this configuration to semantically correct.
1174+
*/
1175+
if (!mockFrameworkInstalled && staticsMockingIsConfigured) {
1176+
this.staticsMockingIsConfigured = false
11641177
}
11651178
}
11661179
}

0 commit comments

Comments
 (0)