Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unit testing Custom htmlhelpers

Status
Not open for further replies.

dinger2121

Programmer
Sep 11, 2007
439
US
Hello,
I have a few custom htmlhelpers that I have created. I have not yet created unit test for these, but would like to have them going forward. I have seen some good posts elsewhere ( regarding using rhino mocks to mock the htmlhelper object in order to unit test the custom helpers.

I was just wondering if anyone else is unit testing their custom htmlhelpers and if so, how they are doing it. Also, is it really worth testing these, or could that be considered overkill?

Thanks for any thoughts.

carl
MCSD, MCTS:MOSS
 
I try to test as much as possible. making the determination of what to test isn't about the type of object, but the context in which the object is used.

for example, I may test a series of objects together because there is not much value in testing each piece individually. this is more common with infrastructure code. testing a SM registry or Windsor Facility are good examples. on the other hand if I'm testing the process of order completion, I would test each piece individually. this helps me drive out design.

if your helpers are not dependent upon HttpContext you should be able to test without much difficulty.

if no tests exists then adding a test or two for the object isn't overkill. if you have a green test for a simple helper you should be just fine. as functionality is added, or a bug is discovered write the failing test first, then make it pass.

I find it's much easier to write test either before or during the design of the actual object. trying to retrofit an object into a test harness can be tedious.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top