locked
Why MVC best for UNIT test and not webforms if there is BL and Input Validation Layer? RRS feed

  • Question

  • User619554136 posted

    Hi,

    ASP.NET MVC sessions and books say ASP.NET MVC enables to do unit testing as logic would be in controller independent to HTTP Request. So that controller can be unit tested indivisually. I do not think so people write their bussiness logic in controllers rather in seperate bussiness layer assembly. So there is no need to test controllers in bussiness perspective.

    I do not think so we write web applications without a seperate Bussiness Layer. In this case Bussiness Layer also a clear seperation from UI. So BL can also be tested very well using UNIT testing frameworks either in MVC or in webforms.

    then why should we chose ASP.NET MVC over WebForms in terms of UNIT Testing. Could anyone please clarify me in this regard if I'm wrong?

    Saturday, February 26, 2011 3:33 PM

All replies

  • User1682618242 posted

    You can do UI logic unit testing not Business Logic testing.

    You can test what happens when a user clicks a link (calling a controller's action) and even test the result (as you get an ActionResult). You can't do that easily in Web Forms

    Saturday, February 26, 2011 3:51 PM
  • User619554136 posted

    You can test what happens when a user clicks a link (calling a controller's action)

    Think of it, once I receive data into Webforms event handler, Only i do is just fill DTO and pass it to Validation Layer. So I can even test UI input validations before calling BL functions.

    But testing of UI style and all, I hope these also can not be tested using controllers. as controllers does not know about UI components in MVC. So I did not see any advantage in ASP.NET MVC in terms of UI testing perspective. Could you please specify any real time example?

    and even test the result (as you get an ActionResult). You can't do that easily in Web Forms

    Could you please specify any real time example also for this?

    Saturday, February 26, 2011 4:52 PM
  • User619554136 posted

    I would appreciate if anyone could share some inputs on this please.

    Thursday, April 14, 2011 4:43 PM