Skip to content

Commit 169ad42

Browse files
authored
Fix unwanted fields in test class for Spring #2170 (#2185)
1 parent da4ba4a commit 169ad42

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/models/builders/SpringTestClassModelBuilder.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ class SpringTestClassModelBuilder(val context: CgContext): TestClassModelBuilder
101101
}
102102
}
103103
is UtCompositeModel -> {
104+
// Here we traverse fields only.
105+
// Traversing mocks as well will result in wrong models playing
106+
// a role of class fields with @Mock annotation.
104107
currentModel.fields.values.forEach { collectRecursively(it, allModels) }
105-
currentModel.mocks.values.asSequence().flatten().forEach { collectRecursively(it, allModels) }
106108
}
107109
is UtAssembleModel -> {
108110
currentModel.origin?.let { collectRecursively(it, allModels) }

0 commit comments

Comments
 (0)