Skip to content

Commit d79a58d

Browse files
committed
Refactor CgTestClassConstructor
1 parent 1b2a733 commit d79a58d

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.utbot.framework.codegen.domain.models.TestClassModel
1212
import org.utbot.framework.codegen.domain.context.CgContext
1313
import org.utbot.framework.codegen.renderer.CgAbstractRenderer
1414
import org.utbot.framework.codegen.reports.TestsGenerationReport
15-
import org.utbot.framework.codegen.tree.CgTestClassConstructor
15+
import org.utbot.framework.codegen.tree.CgSimpleTestClassConstructor
1616
import org.utbot.framework.codegen.tree.ututils.UtilClassKind
1717
import org.utbot.framework.codegen.services.language.CgLanguageAssistant
1818
import org.utbot.framework.plugin.api.ClassId
@@ -73,7 +73,7 @@ open class CodeGenerator(
7373
val cgTestSets = testSets.map { CgMethodTestSet(it) }.toList()
7474
return withCustomContext(testClassCustomName) {
7575
context.withTestClassFileScope {
76-
val astConstructor = CgTestClassConstructor(context)
76+
val astConstructor = CgSimpleTestClassConstructor(context)
7777
val renderer = CgAbstractRenderer.makeRenderer(context)
7878
val testClassModel = TestClassModel.fromTestSets(classUnderTest, cgTestSets)
7979

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgTestClassConstructor.kt renamed to utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgSimpleTestClassConstructor.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ import org.utbot.framework.plugin.api.util.description
3434
import org.utbot.framework.plugin.api.util.humanReadableName
3535
import org.utbot.fuzzer.UtFuzzedExecution
3636

37-
open class CgTestClassConstructor(context: CgContext): CgTestClassConstructorBase(context) {
37+
/**
38+
* This test class constructor is used for pure Java/Kotlin applications.
39+
*/
40+
open class CgSimpleTestClassConstructor(context: CgContext): CgTestClassConstructorBase(context) {
3841

3942
init {
4043
clearContextRelatedStorage()

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgTestClassConstructorBase.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ abstract class CgTestClassConstructorBase(val context: CgContext):
1818
protected open val testFrameworkManager: TestFrameworkManager = CgComponents.getTestFrameworkManagerBy(context)
1919

2020
/**
21-
* Given a testClass model constructs CgTestClass
21+
* Constructs a file with the test class corresponding to [TestClassModel].
2222
*/
2323
open fun construct(testClassModel: TestClassModel): CgClassFile {
2424
return buildClassFile {
@@ -27,6 +27,9 @@ abstract class CgTestClassConstructorBase(val context: CgContext):
2727
}
2828
}
2929

30+
/**
31+
* Constructs [CgClass] corresponding to [TestClassModel].
32+
*/
3033
open fun constructTestClass(testClassModel: TestClassModel): CgClass {
3134
return buildClass {
3235
id = currentTestClass

utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonCgTestClassConstructor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package org.utbot.python.framework.codegen.model.constructor.tree
33
import org.utbot.framework.codegen.domain.models.TestClassModel
44
import org.utbot.framework.codegen.domain.context.CgContext
55
import org.utbot.framework.codegen.domain.models.CgClassFile
6-
import org.utbot.framework.codegen.tree.CgTestClassConstructor
6+
import org.utbot.framework.codegen.tree.CgSimpleTestClassConstructor
77
import org.utbot.framework.codegen.tree.buildClassFile
88

9-
internal class PythonCgTestClassConstructor(context: CgContext) : CgTestClassConstructor(context) {
9+
internal class PythonCgTestClassConstructor(context: CgContext) : CgSimpleTestClassConstructor(context) {
1010
override fun construct(testClassModel: TestClassModel): CgClassFile {
1111
return buildClassFile {
1212
this.declaredClass = withTestClassScope {

0 commit comments

Comments
 (0)