@@ -79,7 +79,8 @@ class CodeGenerator(
79
79
CodeGenerationResult (
80
80
generatedCode = renderClassFile(testClassFile),
81
81
utilClassKind = UtilClassKind .fromCgContextOrNull(context),
82
- testsGenerationReport = testClassFile.testsGenerationReport
82
+ testsGenerationReport = testClassFile.testsGenerationReport,
83
+ mockFrameworkUsed = context.mockFrameworkUsed
83
84
)
84
85
}
85
86
}
@@ -113,12 +114,14 @@ class CodeGenerator(
113
114
* @property generatedCode the source code of the test class
114
115
* @property utilClassKind the kind of util class if it is required, otherwise - null
115
116
* @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
116
118
*/
117
119
data class CodeGenerationResult (
118
120
val generatedCode : String ,
119
121
// null if no util class needed, e.g. when we are using a library or generating utils directly into test class
120
122
val utilClassKind : UtilClassKind ? ,
121
- val testsGenerationReport : TestsGenerationReport
123
+ val testsGenerationReport : TestsGenerationReport ,
124
+ val mockFrameworkUsed : Boolean = false
122
125
)
123
126
124
127
/* *
@@ -176,6 +179,7 @@ sealed class UtilClassKind(
176
179
* or they will be generated directly into the test class (in this case provider will be [TestClassUtilMethodProvider])
177
180
*/
178
181
internal fun fromCgContextOrNull (context : CgContext ): UtilClassKind ? {
182
+ if (context.requiredUtilMethods.isEmpty()) return null
179
183
val provider = context.utilMethodProvider as ? UtilClassFileMethodProvider ? : return null
180
184
if (! context.mockFrameworkUsed) {
181
185
return RegularUtUtils (provider)
0 commit comments