<p>I'm trying to test a simple WebForms (asp.net) based UI, and follow the MVP pattern to allow my UI to be more testable. </p>

<p>As I follow the TDD methodology for backend algorithms, I find that there are some unit test refactorings that happen in the spirit of the DRY principle (Don't Repeat Yourself). As I try to apply this to the UI using Rhino Mocks to verify my interactions, I see many commonalities in the Controller tests when setting up the view or model expectations.</p>

<p>My question is:  how far do you typically take this refactoring, if at all? I'm curious to see how other TDDer's test their MVC/MVP based UIs.</p>

[{'answer_id': 59918, 'author': 'Carlton Jenke', 'author_id': 1215, 'author_profile': 'https://Stackoverflow.com/users/1215', 'pm_score': 0, 'selected': False, 'text': "<p>I use MVP, and on my tests I try to apply most of the refactoring I would in standard code. It normally doesn't work quite as well on the tests, due to the slight variations needed to test different scenarios, but within parts there can be commonality, and when possible I do consolidate. This does ease the needed changes later as the project evolves; just like in your standard code it is easier to change one place instead of 20.</p>\n"}, {'answer_id': 78499, 'author': 'Aaron Jensen', 'author_id': 11229, 'author_profile': 'https://Stackoverflow.com/users/11229', 'pm_score': 1, 'selected': False, 'text': '<p>I would not refactor tests like standard code. Tests start to become more obscure as you refactor things into common base classes, helper methods, etc. Tests should be sufficiently clear on their own. </p>\n\n<p>DRY is not a test concern.</p>\n\n<p>That said, there are many plumbing things that are commonly done, and those should be abstracted away. </p>\n'}, {'answer_id': 155236, 'author': 'Lorenzo Boccaccia', 'author_id': 2273540, 'author_profile': 'https://Stackoverflow.com/users/2273540', 'pm_score': 0, 'selected': False, 'text': "<p>I'd prefer to treat unit test as pure functional programs, to avoid to have to test them. If an operation is enough common in between tests, then I would evaluate it for the standard codebase, but even then I'd avoid refactoring tests, because I tend to have lots of them, specially for gui driven BL.</p>\n"}, {'answer_id': 155258, 'author': 'Daniel Honig', 'author_id': 1129162, 'author_profile': 'https://Stackoverflow.com/users/1129162', 'pm_score': 0, 'selected': False, 'text': "<p>I use selenium for functional testing\nand I'm using JUnit to test my controllers.</p>\n\n<p>I'll mock out services or resources used by the controller and test to see what URI the controller is redirecting to, etc...</p>\n\n<p>The only thing I'm not really testing at this point are the views.  But I have employed functional testing to compensate.</p>\n"}]
['https://Stackoverflow.com/questions/59859', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5619/']