0
我开始与斯卡拉的一个新项目。我想用Specs2测试我的组件。但我已经失去了一个半小时来解决模拟验证问题。Specs2,顺序与否
我的规格如下:
Creating a page should
Verify that the name is not empty
Verify that the name is unique
Produce and store the page
我有我的仓库模拟,这样我可以确认的是,当一个前提条件失败,页面没有存储:
there was no(pages).add(any[Page])
但是最后句子,我验证页面是否存储。
there was one(pages).add(page)
但我的规格是失败,因为最后的测试是在第二个之前做出,因而there was one(pages).add(...)
所以我必须添加sequential
关键字。
我做错了什么?我可以为每个示例创建一个模拟,使其没有副作用。或者我可以在每个例子之前重新设置模拟?
或者在使用mock进行测试时使用sequential
正常吗?
非常感谢。