Created
December 30, 2023 11:01
-
-
Save FouomaOscar/37301c7caa4363000d6d089c1166f93e to your computer and use it in GitHub Desktop.
kotlin test example with mockk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
plugins { | |
kotlin("jvm") version "1.8.0" | |
application | |
} | |
group = "me.shantiswaruptunga" | |
version = "1.0-SNAPSHOT" | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") | |
implementation("javax.xml.bind:jaxb-api:2.3.1") | |
testImplementation(kotlin("test")) | |
testImplementation("io.mockk:mockk:1.12.4") | |
} | |
tasks.test { | |
useJUnitPlatform() | |
} | |
tasks.withType<KotlinCompile> { | |
kotlinOptions.jvmTarget = "1.8" | |
} | |
application { | |
mainClass.set("MainKt") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
distributionBase=GRADLE_USER_HOME | |
distributionPath=wrapper/dists | |
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | |
zipStoreBase=GRADLE_USER_HOME | |
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.mockk.every | |
import io.mockk.mockk | |
import org.junit.jupiter.api.Test | |
import org.w3c.dom.Node | |
class XmlTest { | |
@Test | |
fun test2() { | |
val node1 = mockk<Node>() | |
every { node1.nodeName } returns "x" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment