kotlin - Mockito 如何验证分配?
问题描述
是的,我知道我不应该测试状态而是行为,但是 Android AdMob 实施要求我将 a 分配FullScreenContentCallback
给返回的InterstitialAd
并且我想测试它是否发生:
override fun onAdLoaded(ad: InterstitialAd) {
ad.fullScreenContentCallback = FullscreenPluginCallback(InterstitialAdPluginPluginEvent, notifyListenersFunction)
}
我需要测试ad.fullScreenContentCallback
分配的。我努力了
listener.onAdLoaded(interstitialAdMock)
assertNotNull(interstitialAdMock.fullScreenContentCallback)
AdInterstitialExecutor.interstitialAd = null
var contentCallback: FullScreenContentCallback? = null
Mockito.`when`(interstitialAdMock.fullScreenContentCallback).thenReturn(contentCallback)
val listener = InterstitialAdCallbackAndListeners.getInterstitialAdLoadCallback(pluginCall, notifierMock)
// ACt
listener.onAdLoaded(interstitialAdMock)
assertNotNull(contentCallback)
解决方案
推荐阅读
- c# - 返回 Page() 后会发生什么;
- maven - 如何修复 GeoMesa+HBase POM 中的类路径问题
- java - 在 Jackson 中创建一个空的数组列表
- python-3.x - 如何让我的不和谐机器人从我的电脑播放音频文件
- r - 无法在 Shiny 中解除状态
- c# - 在 Linq 查询 EF Core 中使用 Like
- node.js - 用于 Node.js 的 Dockerfile,将 Python 部署到 AWS Elastic Beanstalk
- mysql - mariadb 输出中的破折号太多
- xcode - Xcode 调试 - 你如何知道下一个方法调用是什么?
- c - 尝试使用 pdcurses 扩展库时出现与 gdi32 相关的错误