@@ -101,7 +101,7 @@ object CodeGenerationController {
101
101
val file = testClass.containingFile
102
102
runWriteCommandAction(model.project, " Generate tests with UtBot" , null , {
103
103
try {
104
- generateCodeAndReport(testClass, file, testSets, model, latch, reports)
104
+ generateCodeAndReport(srcClass, testClass, file, testSets, model, latch, reports)
105
105
} catch (e: IncorrectOperationException ) {
106
106
showCreatingClassError(model.project, createTestClassName(srcClass))
107
107
}
@@ -251,31 +251,27 @@ object CodeGenerationController {
251
251
}
252
252
253
253
private fun generateCodeAndReport (
254
+ srcClass : PsiClass ,
254
255
testClass : PsiClass ,
255
256
file : PsiFile ,
256
257
testSets : List <UtMethodTestSet >,
257
258
model : GenerateTestsModel ,
258
259
reportsCountDown : CountDownLatch ,
259
260
reports : MutableList <TestsGenerationReport >,
260
261
) {
261
- val selectedMethods = TestIntegrationUtils .extractClassMethods(testClass, false )
262
- val testFramework = model.testFramework
263
- val mockito = model.mockFramework
264
- val staticsMocking = model.staticsMocking
265
-
266
262
val classUnderTest = testSets.first().method.clazz
267
-
268
- val params = DumbService .getInstance(model.project)
269
- .runReadActionInSmartMode(Computable { findMethodParams (classUnderTest, selectedMethods ) })
263
+ val classMethods = TestIntegrationUtils .extractClassMethods(srcClass, false )
264
+ val paramNames = DumbService .getInstance(model.project)
265
+ .runReadActionInSmartMode(Computable { findMethodParamNames (classUnderTest, classMethods ) })
270
266
271
267
val codeGenerator = CodeGenerator (
272
268
classUnderTest = classUnderTest.java,
273
- params = params .toMutableMap(),
274
- testFramework = testFramework,
275
- mockFramework = mockito ,
269
+ paramNames = paramNames .toMutableMap(),
270
+ testFramework = model. testFramework,
271
+ mockFramework = model.mockFramework ,
276
272
codegenLanguage = model.codegenLanguage,
277
273
parameterizedTestSource = model.parametrizedTestSource,
278
- staticsMocking = staticsMocking,
274
+ staticsMocking = model. staticsMocking,
279
275
forceStaticMocking = model.forceStaticMocking,
280
276
generateWarningsForStaticMocking = model.generateWarningsForStaticMocking,
281
277
runtimeExceptionTestsBehaviour = model.runtimeExceptionTestsBehaviour,
@@ -348,7 +344,7 @@ object CodeGenerationController {
348
344
}
349
345
}
350
346
351
- private fun findMethodParams (clazz : KClass <* >, methods : List <MemberInfo >): Map <ExecutableId , List <String >> {
347
+ private fun findMethodParamNames (clazz : KClass <* >, methods : List <MemberInfo >): Map <ExecutableId , List <String >> {
352
348
val bySignature = methods.associate { it.signature() to it.paramNames() }
353
349
return clazz.functions
354
350
.mapNotNull { method -> bySignature[method.signature()]?.let { params -> method.executableId to params } }
0 commit comments