IntelliJ IDEA Not Following File and Code Templates for Generated Kotlin Test Files
已回答
Hello JetBrains Community, I've been using IntelliJ IDEA for Kotlin development and I've run into an issue with generating test files. I've set up file and code templates for Kotlin files, and when I create a new Kotlin file manually, this template is applied correctly. but when I generate test classes or methods ("Generate Test" option in the context menu) , IntelliJ IDEA doesn't seem to follow these templates. Here's an example of what I'm trying to achieve in my file template:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
/*
* File: ${NAME}.kt
* Author: Author name
* Created on: ${DATE} ${TIME}
* Description: Author description
*/
#end
#parse("File Header.java")
请先登录再写评论。
I figured out that I should modify the class template located in the code section, not the files section. It turns out that IntelliJ IDEA uses different templates for generating test classes compared to regular file creation.
Please mark this post as solved.
Hello, Anouar Doukkali. Thank you for the update; I'm glad you solved the problem.
Please let me know in case of any questions or requests.