1
0
Fork 0

For #5274: Fix LogTest unit tests (#5275)

master
Colin Lee 2019-09-12 15:41:56 -05:00 committed by GitHub
parent 93ba506722
commit df8aed9158
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

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