Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Kotlin Application with Gradle
plugins {
kotlin("jvm") version "1.3.50"
application
}
repositories {
jcenter()
}
dependencies {
implementation(kotlin("stdlib", "1.3.50"))
testImplementation("junit:junit:4.12")
}
application {
mainClassName = "app.smth.kotlin.MyLibrary"
}
package app.smth.kotlin
data class Language(val name: String, val hotness: Int)
class MyLibrary {
fun kotlinLanguage() = Language("Kotlin", 10)
companion object {
@JvmStatic
fun main(args: Array<String>) {
val languageName = MyLibrary().kotlinLanguage().name
println("My favorite language is $languageName")
}
}
}
package app.smth.kotlin
import org.junit.Assert.assertEquals
import org.junit.Test
class MyLibraryTest {
@Test fun testMyLanguage() {
assertEquals("Kotlin", MyLibrary().kotlinLanguage().name)
assertEquals(10, MyLibrary().kotlinLanguage().hotness)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment