i-3: Add Mokkery as a mocking library #6
@ -1,6 +1,12 @@
|
||||
val versions = mapOf(
|
||||
"kotlinx-datetime" to "0.6.2"
|
||||
)
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.androidLibrary)
|
||||
id("dev.mokkery") version "2.0.0"
|
||||
kotlin("plugin.allopen") version "2.1.10"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@ -25,7 +31,7 @@ kotlin {
|
||||
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
//put your multiplatform dependencies here
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:${versions["kotlinx-datetime"]}")
|
||||
}
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
@ -44,3 +50,8 @@ android {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
allOpen {
|
||||
annotation("com.tle.astrologylibrary.OpenForMokkery")
|
||||
// annotations("com.another.Annotation", "com.third.Annotation")
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
package com.tle.astrologylibrary
|
||||
|
||||
annotation class OpenForMokkery()
|
||||
@ -0,0 +1,7 @@
|
||||
package com.tle.astrologylibrary
|
||||
|
||||
@OpenForMokkery
|
||||
class A constructor()
|
||||
@OpenForMokkery
|
||||
class B constructor()
|
||||
class Subject(val a: A, val b: B)
|
||||
@ -0,0 +1,16 @@
|
||||
package com.tle.astrologylibrary
|
||||
|
||||
import dev.mokkery.mock
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class SubjectTest {
|
||||
@Test
|
||||
fun testCreateSubject() {
|
||||
val a = mock<A> {}
|
||||
val b = mock<B> {}
|
||||
val subject = Subject(a, b)
|
||||
assertEquals(a, subject.a)
|
||||
assertEquals(b, subject.b)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user