views:

320

answers:

2

Recently i heard a dicussion in which TDD was the hot buzz word. Now acc to one speaker that to test your behaviors you need to use MVC but on the other side its been said that TDD is an approach which can be adopted in any environment (as the discussion sorround between ASP.NET MVC or Webforms). The other guy claimed if you put your behaviors in library or models then you can just test your repository or services in TDD and hence dont need to mingle with HTML or div's testing in both cases. What you think how much TDD should cover in case of Web GUI testing or is it worth the effort?

my question is more for Web GUI like HTML stuff we sent over the wire. so basically we should sum like this "does testing the web GUI is worth the effort?" as i wanted to see the prospective of other peers as i often seen that we use some buzz technologies to extreme which is not real benefit of real development scenario's. In other words cant we achieve the TDD with webforms as well or not?

I agree with you guys and thats actually my point too that if you really cater for TDD then you dont need to test your WEB UI front end as the data that you spitting out should be under your business/services/repositories layers which can be tested without it. So if you prgoram WebForm application in such a way that your operations/behaviors are tied in with server side calls (like button click events although in my point they can be tested by calling lower level operations) you can have TDD in web Forms . Thanks for your answers

+3  A: 

I will be bold enough to say that if you need to unit test your GUI in order to get business logic, or integration testing done, then your design is lacking a clean separation of concerns. Both MVC and MVP are patterns that offer a clean separation of concerns so your UI can focus solely on presentation logic.

You do have both options in ASP.Net using either ASP.Net MVC, or WCSF (an MVP implentation using web forms).

That being said, you should still do GUI testing, but you have no need to do all this manually. Selenium Server, and Selenium Remote Control offer ways to do automated testing through the UI.

Josh
+1  A: 

I agree with Josh here. Just getting going on SO, though, so I can't vote it up.

It should be noted firstly that testing your GUI is not unit testing. With clean separation of concerns, as Josh advocated, the GUI contains no business logic.

The logic that requires testing is encapsulated in one or more discrete libraries (or possibly in simple MVC controllers).

TDD refers only to logical code units, and one hallmark of solid TDD practice is that all of your logic code can be written and tested without any UI at all. In fact, tests are often written before the classes they will test. Once code is complete and all tests pass, the UI can be added to utilize the API hooks you've built, and that UI can be webforms, MVC, WPF, winforms, etc.

Testing on the UI that you'll do with a product like Selenium has more to do with acceptance testing or possibly integration testing.

Jay
Very much so Jay :) Thanks for the added clarity to the overall response.
Josh