@@ -18,6 +18,8 @@ import org.utbot.common.trace
18
18
import org.utbot.engine.EngineController
19
19
import org.utbot.engine.Mocker
20
20
import org.utbot.engine.UtBotSymbolicEngine
21
+ import org.utbot.engine.util.mockListeners.ForceMockListener
22
+ import org.utbot.engine.util.mockListeners.ForceStaticMockListener
21
23
import org.utbot.framework.TestSelectionStrategyType
22
24
import org.utbot.framework.UtSettings
23
25
import org.utbot.framework.UtSettings.checkSolverTimeoutMillis
@@ -35,6 +37,8 @@ import org.utbot.framework.plugin.api.util.intArrayClassId
35
37
import org.utbot.framework.plugin.api.util.utContext
36
38
import org.utbot.framework.plugin.api.util.withUtContext
37
39
import org.utbot.framework.plugin.services.JdkInfo
40
+ import org.utbot.framework.util.Conflict
41
+ import org.utbot.framework.util.ConflictTriggers
38
42
import org.utbot.framework.util.SootUtils
39
43
import org.utbot.framework.util.jimpleBody
40
44
import org.utbot.framework.util.toModel
@@ -153,6 +157,10 @@ open class TestCaseGenerator(
153
157
val method2executions = methods.associateWith { mutableListOf<UtExecution >() }
154
158
val method2errors = methods.associateWith { mutableMapOf<String , Int >() }
155
159
160
+ val conflictTriggers = ConflictTriggers ()
161
+ val forceMockListener = ForceMockListener .create(this , conflictTriggers, cancelJob = false )
162
+ val forceStaticMockListener = ForceStaticMockListener .create(this , conflictTriggers, cancelJob = false )
163
+
156
164
runIgnoringCancellationException {
157
165
runBlockingWithCancellationPredicate(isCanceled) {
158
166
for ((method, controller) in method2controller) {
@@ -172,14 +180,23 @@ open class TestCaseGenerator(
172
180
)
173
181
174
182
engineActions.map { engine.apply (it) }
183
+ engineActions.clear()
175
184
176
185
generate(engine)
177
186
.catch {
178
187
logger.error(it) { " Error in flow" }
179
188
}
180
189
.collect {
181
190
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
+ }
183
200
is UtError -> method2errors.getValue(method).merge(it.description, 1 , Int ::plus)
184
201
}
185
202
}
@@ -189,6 +206,7 @@ open class TestCaseGenerator(
189
206
}
190
207
}
191
208
controller.paused = true
209
+ conflictTriggers.reset(Conflict .ForceMockHappened , Conflict .ForceStaticMockHappened )
192
210
}
193
211
194
212
// All jobs are in the method2controller now (paused). execute them with timeout
@@ -226,6 +244,8 @@ open class TestCaseGenerator(
226
244
}
227
245
ConcreteExecutor .defaultPool.close() // TODO: think on appropriate way to close instrumented processes
228
246
247
+ forceMockListener.detach(this , forceMockListener)
248
+ forceStaticMockListener.detach(this , forceStaticMockListener)
229
249
230
250
return methods.map { method ->
231
251
UtMethodTestSet (
0 commit comments