When to Expect and When to Stub?

前端 未结 3 848
旧时难觅i
旧时难觅i 2020-12-29 09:31

I use NMock2, and I\'ve drafted the following NMock classes to represent some common mock framework concepts:

  • Expect: this specifies what a mock

3条回答
  •  长发绾君心
    2020-12-29 09:43

    Well... IMHO it can't be simpler: if your test is about ensuring your Presenter will call Save, do an Expect. if your test is about ensuring your Presenter will handle exception gracefully if Save throws up, do a Stub.

    For more details, check out this podcast by Hanselman and Osherove (author of The Art Of Unit Testing)

提交回复
热议问题