Skip to content

Commit 44e1de9

Browse files
authored
Corrected synthetic FuzzedMethodDescription for fuzzing thisInstance #892 (#897)
1 parent 39354b1 commit 44e1de9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,12 @@ class UtBotSymbolicEngine(
393393
val fallbackModelProvider = FallbackModelProvider(defaultIdGenerator)
394394
val constantValues = collectConstantsForFuzzer(graph)
395395

396+
val syntheticMethodForFuzzingThisInstanceDescription =
397+
FuzzedMethodDescription("thisInstance", voidClassId, listOf(classUnderTest), constantValues).apply {
398+
className = classUnderTest.simpleName
399+
packageName = classUnderTest.packageName
400+
}
401+
396402
val random = Random(0)
397403
val thisInstance = when {
398404
methodUnderTest.isStatic -> null
@@ -406,7 +412,7 @@ class UtBotSymbolicEngine(
406412
}
407413
else -> {
408414
ObjectModelProvider(defaultIdGenerator).withFallback(fallbackModelProvider).generate(
409-
FuzzedMethodDescription("thisInstance", voidClassId, listOf(classUnderTest), constantValues)
415+
syntheticMethodForFuzzingThisInstanceDescription
410416
).take(10).shuffled(random).map { it.value.model }.first().apply {
411417
if (this is UtNullModel) { // it will definitely fail because of NPE,
412418
return@flow
@@ -431,11 +437,7 @@ class UtBotSymbolicEngine(
431437
fuzz(methodUnderTestDescription, modelProvider(defaultModelProviders(defaultIdGenerator)))
432438
} else {
433439
// in case a method with no parameters is passed fuzzing tries to fuzz this instance with different constructors, setters and field mutators
434-
val thisMethodDescription = FuzzedMethodDescription("thisInstance", voidClassId, listOf(classUnderTest), constantValues).apply {
435-
className = classUnderTest.simpleName
436-
packageName = classUnderTest.packageName
437-
}
438-
fuzz(thisMethodDescription, ObjectModelProvider(defaultIdGenerator).apply {
440+
fuzz(syntheticMethodForFuzzingThisInstanceDescription, ObjectModelProvider(defaultIdGenerator).apply {
439441
totalLimit = 500
440442
})
441443
}.withMutations(

0 commit comments

Comments
 (0)