首页 > 解决方案 > 如何使用 scalamock lib 模拟 org.apache.spark.streaming.State?

问题描述

我为 Spark.streaming.mapWithState 的“更新函数”编写了一个单元测试,我需要模拟“org.apache.spark.streaming.State”参数,但它是一个密封类,编译器抱怨一个异常:从密封的非法继承类状态。我应该如何测试我的功能?

标签: unit-testingapache-sparkscalamock

解决方案


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.


推荐阅读