Skip to content

Commit b9dc4f6

Browse files
committed
Generate std tests for symbolic executions with mocking instead of skipping them
1 parent 83750d3 commit b9dc4f6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.utbot.framework.plugin.api.ClassId
3939
import org.utbot.framework.plugin.api.MethodId
4040
import org.utbot.framework.plugin.api.UtExecutionSuccess
4141
import org.utbot.framework.plugin.api.UtMethodTestSet
42+
import org.utbot.framework.plugin.api.UtSymbolicExecution
4243
import org.utbot.framework.plugin.api.util.description
4344
import org.utbot.framework.plugin.api.util.humanReadableName
4445
import org.utbot.fuzzer.UtFuzzedExecution
@@ -211,16 +212,28 @@ internal class CgTestClassConstructor(val context: CgContext) :
211212
)
212213
}
213214

215+
val testCaseTestMethods = mutableListOf<CgTestMethod>()
216+
214217
// We cannot track mocking in fuzzed executions,
215218
// so we generate standard tests for each [UtFuzzedExecution].
216219
// [https://github.com/UnitTestBot/UTBotJava/issues/1137]
217-
val testCaseTestMethods = mutableListOf<CgTestMethod>()
218-
for (execution in testSet.executions.filterIsInstance<UtFuzzedExecution>()) {
219-
testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution)
220-
}
220+
testSet.executions
221+
.filterIsInstance<UtFuzzedExecution>()
222+
.forEach { execution ->
223+
testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution)
224+
}
225+
226+
// Also, we generate standard tests for symbolic executions with force mocking.
227+
// [https://github.com/UnitTestBot/UTBotJava/issues/1231]
228+
testSet.executions
229+
.filterIsInstance<UtSymbolicExecution>()
230+
.filter { it.containsMocking }
231+
.forEach { execution ->
232+
testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution)
233+
}
221234

222235
regions += CgSimpleRegion(
223-
"FUZZER: EXECUTIONS for method ${methodUnderTest.humanReadableName}",
236+
"EXECUTIONS for method ${methodUnderTest.humanReadableName}",
224237
testCaseTestMethods,
225238
)
226239
}

0 commit comments

Comments
 (0)