我正在写Martining Fowler的Presentation Model模式之后的Swing应用程序。含有抽象val成员的嘲讽Scala特征
我创建包含的已Swing组件实现的方法抽象声明性状:
trait LabelMethods {
def setText(text: String)
//...
}
trait MainView {
val someLabel: LabelMethods
def setVisible(visible: Boolean)
// ...
}
class MainFrame extends JFrame with MainView {
val someLabel = new JLabel with LabelMethods
// ...
}
class MainPresenter(mainView: MainView) {
//...
mainView.someLabel.setText("Hello")
mainView.setVisible(true)
}
我如何可以模拟使用开源嘲讽框架(EasyMock,Mockito之一MainView
性状的someLabel
成员, JMockit等)进行单元测试?有没有另一个模拟框架,可能是特定于Scala,可以做到这一点?