Colton Idle
10/19/2024, 7:52 PMclass Test1 {
companion object {
@BeforeClass
@JvmStatic
fun setup() {
println("This runs once before all tests in the class")
}
}
@Before
fun setUp() {
println("This runs before each test")
}
@Test
fun testExample1() = runTest {
println("TEST ONE")
}
}
Colton Idle
10/19/2024, 7:52 PMimport junit.framework.TestCase.assertEquals
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.buildJsonObject
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
class Test1 {
companion object {
@BeforeClass
@JvmStatic
fun setup() {
println("This runs once before all tests in the class")
}
}
@Before
fun setUp() {
println("This runs before each test")
}
@Test
fun testExample1() = runTest {
println("TEST ONE")
}
}
Colton Idle
10/19/2024, 7:53 PMplugins {
kotlin("jvm") version "2.0.20"
}
group = "app.rollertoaster"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
}
Colton Idle
10/19/2024, 7:57 PMYoussef Shoaib [MOD]
10/19/2024, 7:58 PMColton Idle
10/19/2024, 8:02 PMColton Idle
10/19/2024, 8:02 PMColton Idle
10/19/2024, 8:02 PMColton Idle
10/19/2024, 8:02 PMYoussef Shoaib [MOD]
10/19/2024, 8:02 PMYoussef Shoaib [MOD]
10/19/2024, 8:03 PMColton Idle
10/19/2024, 8:15 PMephemient
10/20/2024, 3:57 AMephemient
10/20/2024, 3:59 AMephemient
10/20/2024, 4:00 AMuseJUnitPlatform()
) or JUnit 4 (and useJUnit()
) only, to avoid confusionColton Idle
10/20/2024, 4:17 PM