Skip to content

Commit 589d77d

Browse files
committed
Put information about whether mocks were used into CodeGenerationResult
1 parent 079230d commit 589d77d

File tree

1 file changed

+6
-2
lines changed
  • utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model

1 file changed

+6
-2
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/CodeGenerator.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class CodeGenerator(
7979
CodeGenerationResult(
8080
generatedCode = renderClassFile(testClassFile),
8181
utilClassKind = UtilClassKind.fromCgContextOrNull(context),
82-
testsGenerationReport = testClassFile.testsGenerationReport
82+
testsGenerationReport = testClassFile.testsGenerationReport,
83+
mockFrameworkUsed = context.mockFrameworkUsed
8384
)
8485
}
8586
}
@@ -113,12 +114,14 @@ class CodeGenerator(
113114
* @property generatedCode the source code of the test class
114115
* @property utilClassKind the kind of util class if it is required, otherwise - null
115116
* @property testsGenerationReport some info about test generation process
117+
* @property mockFrameworkUsed flag indicating whether any mock objects have been created during code generation ot not
116118
*/
117119
data class CodeGenerationResult(
118120
val generatedCode: String,
119121
// null if no util class needed, e.g. when we are using a library or generating utils directly into test class
120122
val utilClassKind: UtilClassKind?,
121-
val testsGenerationReport: TestsGenerationReport
123+
val testsGenerationReport: TestsGenerationReport,
124+
val mockFrameworkUsed: Boolean = false
122125
)
123126

124127
/**
@@ -176,6 +179,7 @@ sealed class UtilClassKind(
176179
* or they will be generated directly into the test class (in this case provider will be [TestClassUtilMethodProvider])
177180
*/
178181
internal fun fromCgContextOrNull(context: CgContext): UtilClassKind? {
182+
if (context.requiredUtilMethods.isEmpty()) return null
179183
val provider = context.utilMethodProvider as? UtilClassFileMethodProvider ?: return null
180184
if (!context.mockFrameworkUsed) {
181185
return RegularUtUtils(provider)

0 commit comments

Comments
 (0)