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(
|
||||
"kotlinx-datetime" to "0.6.2"
|
||||
"kotlinx-datetime" to "0.6.2",
|
||||
"assertk" to "0.28.1",
|
||||
)
|
||||
|
||||
plugins {
|
||||
@ -35,12 +36,13 @@ kotlin {
|
||||
}
|
||||
commonTest.dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
implementation("com.willowtreeapps.assertk:assertk:${versions["assertk"]}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
Re namespace = "org.tle.astrologylibrary"
|
||||
namespace = "org.tle.astrologylibrary"
|
||||
compileSdk = 35
|
||||
defaultConfig {
|
||||
minSdk = 24
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package org.tle.astrologylibrary
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.contains
|
||||
import org.junit.Test
|
||||
|
||||
class AndroidGreetingTest {
|
||||
|
||||
@Test
|
||||
fun testExample() {
|
||||
assertTrue("Check Android is mentioned", Greeting().greet().contains("Android"))
|
||||
assertThat(Greeting().greet()).contains("Android")
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
package org.tle.astrologylibrary
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import dev.mokkery.mock
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class SubjectTest {
|
||||
@Test
|
||||
@ -10,7 +11,7 @@ class SubjectTest {
|
||||
val a = mock<A> {}
|
||||
val b = mock<B> {}
|
||||
val subject = Subject(a, b)
|
||||
assertEquals(a, subject.a)
|
||||
assertEquals(b, subject.b)
|
||||
assertThat(subject.a).isEqualTo(a)
|
||||
assertThat(subject.b).isEqualTo(b)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package org.tle.astrologylibrary
|
||||
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.contains
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class CommonGreetingTest {
|
||||
|
||||
@Test
|
||||
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