Can we unit test View ('V') of MVC?

后端 未结 5 675
走了就别回头了
走了就别回头了 2021-01-12 05:17

Duplicate: Unit Testing the Views?

Is there any way to unit test View? I am sure that we can test Model & Controller but don\'t know

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 05:47

    You can enable compilation of MVC views. That helps a lot. Otherwise, I don't think it is worth it. After all, the there are only two things that you are interested in. Does view compile and do you get any exceptions (null, out of bounds exceptions, or similar)?

    There are some folks who claim that you should not include any logic in view. Write helpers for anything. In that case, compilation is pretty much everything you'll want.

    We decided to invest into WatiN testing. It tests views and it tests the whole app at the same time. Has some nice helpers, but requires constant maintainance.

提交回复
热议问题