i-5: Introduce fluent assertions in unit tests with assertk (#11)
Co-authored-by: Emil Simeonov <emil@theliberatededge.org> Reviewed-on: #11
This commit is contained in:
parent
b986cd98d9
commit
e416ae8119
@ -1,5 +1,6 @@
|
|||||||
val versions = mapOf(
|
val versions = mapOf(
|
||||||
"kotlinx-datetime" to "0.6.2"
|
"kotlinx-datetime" to "0.6.2",
|
||||||
|
"assertk" to "0.28.1",
|
||||||
)
|
)
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@ -35,12 +36,13 @@ kotlin {
|
|||||||
}
|
}
|
||||||
commonTest.dependencies {
|
commonTest.dependencies {
|
||||||
implementation(libs.kotlin.test)
|
implementation(libs.kotlin.test)
|
||||||
|
implementation("com.willowtreeapps.assertk:assertk:${versions["assertk"]}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
Re namespace = "org.tle.astrologylibrary"
|
namespace = "org.tle.astrologylibrary"
|
||||||
compileSdk = 35
|
compileSdk = 35
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
package org.tle.astrologylibrary
|
package org.tle.astrologylibrary
|
||||||
|
|
||||||
import org.junit.Assert.assertTrue
|
import assertk.assertThat
|
||||||
|
import assertk.assertions.contains
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class AndroidGreetingTest {
|
class AndroidGreetingTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testExample() {
|
fun testExample() {
|
||||||
assertTrue("Check Android is mentioned", Greeting().greet().contains("Android"))
|
assertThat(Greeting().greet()).contains("Android")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,9 @@
|
|||||||
package org.tle.astrologylibrary
|
package org.tle.astrologylibrary
|
||||||
|
|
||||||
|
import assertk.assertThat
|
||||||
|
import assertk.assertions.isEqualTo
|
||||||
import dev.mokkery.mock
|
import dev.mokkery.mock
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
|
||||||
|
|
||||||
class SubjectTest {
|
class SubjectTest {
|
||||||
@Test
|
@Test
|
||||||
@ -10,7 +11,7 @@ class SubjectTest {
|
|||||||
val a = mock<A> {}
|
val a = mock<A> {}
|
||||||
val b = mock<B> {}
|
val b = mock<B> {}
|
||||||
val subject = Subject(a, b)
|
val subject = Subject(a, b)
|
||||||
assertEquals(a, subject.a)
|
assertThat(subject.a).isEqualTo(a)
|
||||||
assertEquals(b, subject.b)
|
assertThat(subject.b).isEqualTo(b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
package org.tle.astrologylibrary
|
package org.tle.astrologylibrary
|
||||||
|
|
||||||
|
import assertk.assertThat
|
||||||
|
import assertk.assertions.contains
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertTrue
|
|
||||||
|
|
||||||
class CommonGreetingTest {
|
class CommonGreetingTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testExample() {
|
fun testExample() {
|
||||||
assertTrue(Greeting().greet().contains("Hello"), "Check 'Hello' is mentioned")
|
assertThat(Greeting().greet()).contains("Hello")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user