testing scaffolding has been set up

This commit is contained in:
dtookey 2023-08-07 08:05:52 -04:00
parent 1b2b24c317
commit b23c4b348e
4 changed files with 85 additions and 1 deletions

View File

@ -5,6 +5,7 @@
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="openjdk-19" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View File

@ -12,16 +12,30 @@ repositories {
dependencies { dependencies {
testImplementation(kotlin("test")) testImplementation(kotlin("test"))
testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0")
} }
tasks.test { tasks.test {
useJUnitPlatform() useJUnitPlatform()
} }
sourceSets {
test {
kotlin.srcDir("src/test/kotlin")
}
}
kotlin { kotlin {
jvmToolchain(8) jvmToolchain(8)
} }
java {
toolchain{
languageVersion.set(JavaLanguageVersion.of(17))
}
}
application { application {
mainClass.set("EntryKt") mainClass.set("EntryKt")
} }

View File

@ -0,0 +1,11 @@
import kotlin.test.Test
import kotlin.test.assertEquals
class MyTests {
@Test
fun test() {
assertEquals(2, 1 + 1)
}
}

View File

@ -0,0 +1,58 @@
package controllers
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import java.awt.Point
internal class InputControllerTest {
private val mockController = Mockito.mock(InputController::class.java)
@Test
fun `moveMouse delegates to implementation`() {
val point = Point(10, 20)
mockController.moveMouse(point)
Mockito.verify(mockController).moveMouse(point)
}
@Test
fun `mouseClick delegates to implementation`() {
val button = 1
mockController.mouseClick(button)
Mockito.verify(mockController).mouseClick(button)
}
@Test
fun `keyPress delegates to implementation`() {
val keyCode = 65
mockController.keyPress(keyCode)
Mockito.verify(mockController).keyPress(keyCode)
}
@Test
fun `scrollIn delegates to implementation`() {
val sleepDur = 100L
val variance = 50L
mockController.scrollIn(sleepDur, variance)
Mockito.verify(mockController).scrollIn(sleepDur, variance)
}
@Test
fun `scrollOut delegates to implementation`() {
val sleepDur = 100L
val variance = 50L
mockController.scrollOut(sleepDur, variance)
Mockito.verify(mockController).scrollOut(sleepDur, variance)
}
}