Hi all Researching patterns to test-driven-development in frameworks based on the model view controller, I found this interesting paper
http://www.purpletech.com/articles/mvc/mvc-and-beyond.html In this pattern, there ios a mini-MVC for ecah page on top of the global MVC. Quoting "Here, the Page Model (the Page Data objects) represents everything that will show up on the page, in what order, in what language, etc. The page model represents an *overlapping set* with the application model. It does not contain all the information in the application model, merely the subset that is necessary for the current page to render. However, it is not a subset, for it also contains other, additional information: for example, which user is currently logged in, or which page of search results is showing, or an error message based on an invalid field. The Page (View) Renderer objects, in turn, perform a transformation from the Page Data into HTML. The most logic performed by the Renderer should be no more sophisticated than simple conditionals or iteration on values and collections returned by the data model. Finally, the Page Servlet (Controller) receives the parameters, creates an appropriate Page Data (Model), and passes it to a Page Renderer (View)." Thanks to this model, testing in very much incremental Quoting again " *Testability.* MMMVC is much easier to test than previous architectures. You can test that the correct page model gets generated by passing known parameters to the controller and testing the page model it returns. You can also test the renderer by passing a known page model and testing its rendered output. Since UI testing is both more difficult and, arguably, less important (since errors in HTML rendering are more likely to be noticed by humans), you can reserve the bulk of your test cases for the page model. Indeed, some Agile programming teams either do not test the UI at all, or write only rudimentary UI tests; this shortcut is only desirable with a very thin UI layer on top of a full-fledged data model. For instance, if a Menu page must display the Soup du Jour (which changes every day), the page must *not* do Date today = new Date(); int dayOfWeek = today.getDay(); String soup = data.getSoupForDay(dayOfWeek); out.print("Soup du Jour: " + soup); instead, that functionality must be delegated to the Page Model. Why? Because otherwise, it becomes impossible to test that Thursday's correct soup is displayed... unless you're testing on Thursday. out.print("Soup du Jour: " + data.getSoupDuJour()); Note that getSoupDuJour() (with no parameters) is *not* a member of the application data model. You must add it to the Page Model." To apply this approach in pylons: 1) I must create a page-model oriented layer, that generates the specific data that the page controller needs. This is already easy in pylons 2) Given a frozen data-set, pass it to the page-view (template) and check if it is rendered in ehe appropiate way. Well, here is my problem. I don´t know how to make this kind of test. Any advice? Thanks Agustin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
<<inline: mmmvc.png>>
