Skip to content

Commit dc619ae

Browse files
committed
Generate std tests for symbolic executions with mocking instead of skipping them
1 parent 651f7d4 commit dc619ae

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

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

Lines changed: 26 additions & 8 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,18 +212,35 @@ internal class CgTestClassConstructor(val context: CgContext) :
211212
)
212213
}
213214

215+
regions += CgSimpleRegion(
216+
"Tests for method ${methodUnderTest.humanReadableName} that cannot be presented as parameterized",
217+
collectAdditionalTestsForParameterizedMode(testSet),
218+
)
219+
}
220+
221+
private fun collectAdditionalTestsForParameterizedMode(testSet: CgMethodTestSet): List<CgTestMethod> {
222+
val (methodUnderTest, _, _, _) = testSet
223+
val testCaseTestMethods = mutableListOf<CgTestMethod>()
224+
214225
// We cannot track mocking in fuzzed executions,
215226
// so we generate standard tests for each [UtFuzzedExecution].
216227
// [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-
}
228+
testSet.executions
229+
.filterIsInstance<UtFuzzedExecution>()
230+
.forEach { execution ->
231+
testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution)
232+
}
221233

222-
regions += CgSimpleRegion(
223-
"FUZZER: EXECUTIONS for method ${methodUnderTest.humanReadableName}",
224-
testCaseTestMethods,
225-
)
234+
// Also, we generate standard tests for symbolic executions with force mocking.
235+
// [https://github.com/UnitTestBot/UTBotJava/issues/1231]
236+
testSet.executions
237+
.filterIsInstance<UtSymbolicExecution>()
238+
.filter { it.containsMocking }
239+
.forEach { execution ->
240+
testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution)
241+
}
242+
243+
return testCaseTestMethods
226244
}
227245

228246
/**

0 commit comments

Comments
 (0)