如何为TestNG Kotlin项目添加gradle支持?

我目前有一个testot安装Kotlin项目,当我右键单击src/test/kotlin文件夹,并选择Run All Tests 。 有用。

但是当我尝试用gradle输出一个源代码jar(包含测试用例)时,它开始抱怨:

 18:38:08: Executing task 'sourcesJar'... e: /Users/a/codes/objjson/src/test/kotlin/tests.kt: (7, 12): Unresolved reference: testng 
e: /Users/a/codes/objjson/src/test/kotlin/tests.kt: (22, 5): Unresolved reference: assertEquals
e: /Users/a/codes/objjson/src/test/kotlin/tests.kt: (60, 6): Unresolved reference: Test
....... :compileKotlin FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileKotlin'. > Compilation error. See log for more details * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED in 5s 1 actionable task: 1 executed Compilation error. See log for more details 18:38:14: Task execution finished 'sourcesJar'.

我只是尝试在测试文件中导入包:

 import org.testng.Assert import org.testng.annotations.Test import org.testng.AssertJUnit.assertEquals import kotlin.reflect.KClass 

我已经在设置中添加了testng 。 我的build.gradle是:

 plugins { id "org.jetbrains.kotlin.jvm" version "1.2.10" } repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib" compile "org.jetbrains.kotlin:kotlin-reflect" testCompile "org.jetbrains.kotlin:kotlin-test" testCompile 'org.testng:testng:6.13.1' } sourceSets { main.kotlin.srcDirs += 'src/' } task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } artifacts { archives sourcesJar } 

我在这里错过了什么?

我使用最新版本的IDEA