- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的测试课:
class RocketListVMTest {
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()
private lateinit var sut: RocketListVM
private var activeOnlyToggle = false
private val repo: Repo = mock()
@Before
fun setUp() {
sut = RocketListVM(repo)
activeOnlyToggle = false
}
@Test
fun toggleActiveOnlyWithTrueCallsRepository() {
sut.toggleActiveOnly(true)
verify(repo).getActiveOnlyLocalRockets()
}
}
具有以下依赖项:
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.21.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'android.arch.core:core-testing:1.1.1'
我创建了
src/androidTest/resources/mockito-extensions/org.mockito.plugins.MockMaker
与
mock-maker-inline
里面。
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@dd6cba3
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker. (This mock maker is not supported on Android.)
如何解决这个问题? SO答案都没有帮助。
最佳答案
这有效:
dependencies {
testImplementation 'org.mockito:mockito-core:3.8.0'
androidTestImplementation 'org.mockito:mockito-android:3.8.0'
}
有两个包:mockito-core 用于测试,而 mockito-android 用于 android 测试。
关于android - 无法初始化 MockMaker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66343356/
使用 TestNg + PowerMock + Mockito 时遇到 java.lang.ExceptionInInitializerError: Caused by: java.lang.Null
这是我的测试课: class RocketListVMTest { @get:Rule var instantTaskExecutorRule = InstantTaskExecuto
您好,我正在尝试模拟最终类(因为 kotlin 中的所有类默认都是最终类)并在我的 gradle 中添加了以下依赖项: testImplementation 'junit:junit:4.12' te
测试开始后,我收到以下异常: Testcase: treeCtorArgumentTest(com.xythos.client.drive.cachedtree.CachedTreeTest)
使用操作系统独立路径 'mockito-extensions/org.mockito.plugins.MockMaker' 找到多个文件添加时出现此错误androidTestImplementatio
尝试在 AS 上运行仪器测试。 遇到这个错误: java.lang.IllegalStateException: Could not initialize plugin: interface org.
我是用 spring boot 编写 junit4 测试的新手我已经探索了所有 SO 问题来解决以下问题,我进行了广泛的研究,但我无法解决这个问题。我一直在尝试使用 @MockBean 和 @Auto
我正在使用 Mockito 2 和 Espresso 进行单元测试,但在尝试在仪器测试中使用 Mockito 2 时遇到了问题。在运行测试时,我收到此错误 java.lang.IllegalState
我正在尝试使用 PowerMock 通过静态方法模拟一个类,但我特别希望在 Android Instrumentation 测试中执行此操作。明确地说,我希望在真实的 Android 设备或模拟器上运
我收到 PowerMock 错误,但我没有使用 PowerMocking。我正在使用正常的模拟。这是我要测试的类(class): import java.util.List; import org.a
我一直在将一个项目从 Java 8 迁移到 Java 12。除了单元测试外,一切都很顺利。当我使用 Maven 编译和启动测试时,许多测试失败并显示以下消息: java.lang.IllegalSta
我是一名优秀的程序员,十分优秀!