generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): add KotlinMethodContextBuilderTest
This commit adds a new test class `KotlinMethodContextBuilderTest` to test the functionality of the `KotlinMethodContextBuilder` class. The test case `testShouldIgnoreMethodComments` verifies that method comments are ignored when generating the signature string.
- Loading branch information
Showing
3 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
kotlin/src/test/kotlin/cc/unitmesh/kotlin/context/KotlinMethodContextBuilderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cc.unitmesh.kotlin.context; | ||
|
||
import com.intellij.psi.util.PsiTreeUtil | ||
import com.intellij.testFramework.LightPlatformTestCase | ||
import junit.framework.TestCase | ||
import org.jetbrains.kotlin.psi.KtClassOrObject | ||
import org.jetbrains.kotlin.psi.KtNamedFunction | ||
import org.jetbrains.kotlin.psi.KtPsiFactory | ||
import org.junit.Test | ||
|
||
|
||
class KotlinMethodContextBuilderTest : LightPlatformTestCase() { | ||
fun testShouldIgnoreMethodComments() { | ||
// given | ||
val code = """ | ||
/** | ||
* It's a hello, world. | ||
*/ | ||
fun main() { | ||
println("Hello, World!") | ||
} | ||
""".trimIndent() | ||
|
||
val createFile = KtPsiFactory(project).createFile("UserController.kt", code) | ||
val clz = PsiTreeUtil.findChildOfType(createFile, KtNamedFunction::class.java)!! | ||
|
||
val signatureString = KotlinMethodContextBuilder.Util.getSignatureString(clz) | ||
TestCase.assertEquals(signatureString, "fun main()") | ||
} | ||
|
||
/** | ||
* It's a hello, world. | ||
*/ | ||
fun main() { | ||
println("Hello, World!") | ||
} | ||
|
||
} |