unit-testing - 如何使用 scalamock lib 模拟 org.apache.spark.streaming.State?
问题描述
我为 Spark.streaming.mapWithState 的“更新函数”编写了一个单元测试,我需要模拟“org.apache.spark.streaming.State”参数,但它是一个密封类,编译器抱怨一个异常:从密封的非法继承类状态。我应该如何测试我的功能?
解决方案
A sealed trait can only be extended in the same source file as it's declared. So Scalamock has no chance of mocking this type.
推荐阅读
- swift - SecKeyVerifySignature 失败 ecdsaSignatureDigestX962
- javascript - 使用外部函数有条件地渲染组件
- laravel - 如何验证 laravel-admin 中唯一的多个列?
- ios - 如何将 Core Data sqlite 导出到 iCloud 并导入新设备
- javascript - 遍历目录内的所有图像并转换为base64
- azure - 如何处理 Azure 错误“此缩放单元不支持 Premium V2。请考虑重新部署或克隆您的应用程序。”
- web-services - “对象引用未设置为对象的实例”添加新的 WCF 服务时
- asp.net-core - 如何根据需要为 Razor 页面添加脚本和 css 引用?
- composer-php - 无法获取特定版本的作曲家包
- django - 用于实现级联下拉列表的 Vue.js 和 django rest 框架