JetBrains-Research / TestSpark

TestSpark - a plugin for generating unit tests. TestSpark natively integrates different AI-based test generation tools and techniques in the IDE. Started by SERG TU Delft. Currently under implementation by JetBrains Research (Software Testing Research) for research purposes.
MIT License
47 stars 13 forks source link

[Kotlin] Enable top level function tests #266

Closed Frosendroska closed 2 months ago

Frosendroska commented 3 months ago

1. Get rid of the necessity for the function to be inside the class

In Kotlin, there can be a function outside the class.

Therefore, the following code fails when we want to generate.

    private fun createLLMPipeline(
        project: Project,
        psiHelper: PsiHelper,
        caretOffset: Int,
        fileUrl: String?,
        testGenerationController: TestGenerationController,
    ): Pipeline {
        val cutPsiClass = psiHelper.getSurroundingClass(caretOffset)!!
        val packageList = cutPsiClass.qualifiedName.split(".").dropLast(1)
        val packageName = packageList.joinToString(".")
        return Pipeline(project, psiHelper, caretOffset, fileUrl, packageName, testGenerationController)
    }
Frosendroska commented 2 months ago

Fixed in the PR