parent
93ba506722
commit
df8aed9158
|
@ -10,6 +10,7 @@ import io.mockk.mockk
|
||||||
import io.mockk.mockkStatic
|
import io.mockk.mockkStatic
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import org.mozilla.fenix.BuildConfig
|
||||||
|
|
||||||
@ObsoleteCoroutinesApi
|
@ObsoleteCoroutinesApi
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@ -17,18 +18,20 @@ import android.util.Log
|
||||||
|
|
||||||
class LogTest {
|
class LogTest {
|
||||||
|
|
||||||
|
val numCalls = if (BuildConfig.DEBUG) 1 else 0
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Test log debug function`() {
|
fun `Test log debug function`() {
|
||||||
mockkStatic(Log::class)
|
mockkStatic(Log::class)
|
||||||
logDebug("hi", "hi")
|
logDebug("hi", "hi")
|
||||||
verify { (Log.d("hi", "hi")) }
|
verify(exactly = numCalls) { (Log.d("hi", "hi")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Test log warn function with tag and message args`() {
|
fun `Test log warn function with tag and message args`() {
|
||||||
mockkStatic(Log::class)
|
mockkStatic(Log::class)
|
||||||
logWarn("hi", "hi")
|
logWarn("hi", "hi")
|
||||||
verify { (Log.w("hi", "hi")) }
|
verify(exactly = numCalls) { (Log.w("hi", "hi")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -36,7 +39,7 @@ class LogTest {
|
||||||
mockkStatic(Log::class)
|
mockkStatic(Log::class)
|
||||||
val mockThrowable: Throwable = mockk(relaxed = true)
|
val mockThrowable: Throwable = mockk(relaxed = true)
|
||||||
logWarn("hi", "hi", mockThrowable)
|
logWarn("hi", "hi", mockThrowable)
|
||||||
verify { (Log.w("hi", "hi", mockThrowable)) }
|
verify(exactly = numCalls) { (Log.w("hi", "hi", mockThrowable)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -44,6 +47,6 @@ class LogTest {
|
||||||
mockkStatic(Log::class)
|
mockkStatic(Log::class)
|
||||||
val mockThrowable: Throwable = mockk(relaxed = true)
|
val mockThrowable: Throwable = mockk(relaxed = true)
|
||||||
logErr("hi", "hi", mockThrowable)
|
logErr("hi", "hi", mockThrowable)
|
||||||
verify { (Log.e("hi", "hi", mockThrowable)) }
|
verify(exactly = numCalls) { (Log.e("hi", "hi", mockThrowable)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue