@@ -18,6 +18,8 @@ import org.utbot.common.trace
1818import org.utbot.engine.EngineController
1919import org.utbot.engine.Mocker
2020import org.utbot.engine.UtBotSymbolicEngine
21+ import org.utbot.engine.util.mockListeners.ForceMockListener
22+ import org.utbot.engine.util.mockListeners.ForceStaticMockListener
2123import org.utbot.framework.TestSelectionStrategyType
2224import org.utbot.framework.UtSettings
2325import org.utbot.framework.UtSettings.checkSolverTimeoutMillis
@@ -35,6 +37,8 @@ import org.utbot.framework.plugin.api.util.intArrayClassId
3537import org.utbot.framework.plugin.api.util.utContext
3638import org.utbot.framework.plugin.api.util.withUtContext
3739import org.utbot.framework.plugin.services.JdkInfo
40+ import org.utbot.framework.util.Conflict
41+ import org.utbot.framework.util.ConflictTriggers
3842import org.utbot.framework.util.SootUtils
3943import org.utbot.framework.util.jimpleBody
4044import org.utbot.framework.util.toModel
@@ -153,6 +157,10 @@ open class TestCaseGenerator(
153157 val method2executions = methods.associateWith { mutableListOf<UtExecution >() }
154158 val method2errors = methods.associateWith { mutableMapOf<String , Int >() }
155159
160+ val conflictTriggers = ConflictTriggers ()
161+ val forceMockListener = ForceMockListener .create(this , conflictTriggers, cancelJob = false )
162+ val forceStaticMockListener = ForceStaticMockListener .create(this , conflictTriggers, cancelJob = false )
163+
156164 runIgnoringCancellationException {
157165 runBlockingWithCancellationPredicate(isCanceled) {
158166 for ((method, controller) in method2controller) {
@@ -172,14 +180,23 @@ open class TestCaseGenerator(
172180 )
173181
174182 engineActions.map { engine.apply (it) }
183+ engineActions.clear()
175184
176185 generate(engine)
177186 .catch {
178187 logger.error(it) { " Error in flow" }
179188 }
180189 .collect {
181190 when (it) {
182- is UtExecution -> method2executions.getValue(method) + = it
191+ is UtExecution -> {
192+ if (it is UtSymbolicExecution &&
193+ (conflictTriggers.triggered(Conflict .ForceMockHappened ) ||
194+ conflictTriggers.triggered(Conflict .ForceStaticMockHappened ))
195+ ) {
196+ it.containsMocking = true
197+ }
198+ method2executions.getValue(method) + = it
199+ }
183200 is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
184201 }
185202 }
@@ -189,6 +206,7 @@ open class TestCaseGenerator(
189206 }
190207 }
191208 controller.paused = true
209+ conflictTriggers.reset(Conflict .ForceMockHappened , Conflict .ForceStaticMockHappened )
192210 }
193211
194212 // All jobs are in the method2controller now (paused). execute them with timeout
@@ -226,6 +244,8 @@ open class TestCaseGenerator(
226244 }
227245 ConcreteExecutor .defaultPool.close() // TODO: think on appropriate way to close instrumented processes
228246
247+ forceMockListener.detach(this , forceMockListener)
248+ forceStaticMockListener.detach(this , forceStaticMockListener)
229249
230250 return methods.map { method ->
231251 UtMethodTestSet (
0 commit comments