Skip to content

Commit 8e29d07

Browse files
committed
[Bug] Remove mockito and used mockk instead.
1 parent 5838fb5 commit 8e29d07

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

aztec/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ dependencies {
6767
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0', {
6868
exclude group: 'com.android.support', module: 'support-annotations'
6969
}
70-
testImplementation "org.mockito:mockito-inline:$mockitoVersion"
71-
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
70+
testImplementation "io.mockk:mockk:${mockkVersion}"
7271

7372
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"
7473
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutinesVersion"

aztec/src/test/kotlin/org/wordpress/aztec/MarkSpanTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
package org.wordpress.aztec
22

3+
import io.mockk.every
4+
import io.mockk.mockk
35
import org.junit.Assert
46
import org.junit.Test
57
import org.junit.runner.RunWith
6-
import org.mockito.Mock
7-
import org.mockito.Mockito
88
import org.robolectric.RobolectricTestRunner
99
import org.wordpress.aztec.spans.MarkSpan
1010

1111
@RunWith(RobolectricTestRunner::class)
1212
class MarkSpanTest {
13-
@Mock
14-
val markSpan = Mockito.mock(MarkSpan::class.java)
1513
/**
1614
* Test used to confirm two crashes related are fixed.
1715
*
@@ -22,8 +20,9 @@ class MarkSpanTest {
2220
var error = false
2321
var result: Int? = null
2422
try {
25-
Mockito.`when`(markSpan.safelyParseColor("")).thenCallRealMethod()
26-
result = markSpan.safelyParseColor("")
23+
val span = mockk<MarkSpan>()
24+
every { span.safelyParseColor("") } coAnswers { callOriginal() }
25+
result = span.safelyParseColor("")
2726
} catch (e: Exception) {
2827
error = true
2928
}
@@ -41,8 +40,9 @@ class MarkSpanTest {
4140
var error = false
4241
var result: Int? = null
4342
try {
44-
Mockito.`when`(markSpan.safelyParseColor(null)).thenCallRealMethod()
45-
result = markSpan.safelyParseColor(null)
43+
val span = mockk<MarkSpan>()
44+
every { span.safelyParseColor(null) } coAnswers { callOriginal() }
45+
result = span.safelyParseColor(null)
4646
} catch (e: Exception) {
4747
error = true
4848
}

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ ext {
8080
jSoupVersion = '1.11.3'
8181
wordpressUtilsVersion = '3.5.0'
8282
espressoVersion = '3.0.1'
83-
mockitoVersion = '4.5.1'
84-
mockitoKotlinVersion = '4.1.0'
83+
mockkVersion = '1.12.8'
8584

8685
// other
8786
wordpressLintVersion = '2.0.0'

0 commit comments

Comments
 (0)