-
In IntelliJ Idea:
File
=>New
=>Project
-
Select type
Gradle
and inAdditional LIbriries and Framworks
select onlyKotlin/JVM
Open build.gradle
and add to dependencies
block this lines:
testImplementation 'junit:junit:4'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
Here you can see my build.gradle
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.6"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.6"
}
Inside src
=> main
=> kotlin
create file Hello.kt
package main
class Hello {
fun getGreeting(): String {
return "Hello"
}
}
Inside src
=> test
=> kotlin
create file HelloTest.kt
import main.Hello
import kotlin.test.assertEquals
import org.junit.Test as test
class HelloTest {
@test
fun simpleTest() {
val greeting = Hello().getGreeting()
assertEquals(greeting, "Hola")
}
}