开发者

Testing aspx.cs classes? Should I do it?

We are using VS2010 with the 4.0 framework with MS test. So my question is should we create unit tests that call the aspx.cs page? We are using EF 4.0 and the aspx.cs pages call down into our repositories ( Classes that create / setup and remove objects from the context ). So I know that we need these tests but, should the tests call into the aspx.cs pages or should I separate the calls to the repository into another file that can be t开发者_JAVA技巧ested by is self. I've never tried to do something like:

  MyPage1 pg1 = new MyPage1();
  // Test methods..

Thanks


No.

Testing aspx pages is hard and horrible. It sounds as your app is highly coupled if you need to test your views in this manner. Test your repository in isolation, you won't be able to test it in the view but keep the logic simple enough and you should be ok. In other words make your pages simply invoke your repository and return the results.

Alternatively check out adopting a MVC paradigm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜