Announcement Announcement Module
Collapse
No announcement yet.
Testing a View (integration tests) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing a View (integration tests)

    Hi,

    We are using Laszlo, and have a View that spits out an XML representation of the objects that we pass up to the view layer.

    We have integration tests that test our controllers, but would also like to test that the actual XML that is produced by the View is correct (we've been bitten by subtle changes that make the XML change!).

    Has anyone written any integration tests at the View level? Any pointers on how to do so? How can I create the View programmatically from the ModelAndView that is returned?

    Many thanks,

    David

  • #2
    I am not sure that I fully understand your question, but did you check out the tests that are shipped with the distribution in the org.springframework.web.servlet.view package? There is for instance a ExcelViewTests, PdfViewTests, XsltViewTests etc..

    Hope this helps.

    Rgrds, Thomas

    Comment


    • #3
      Hi Thomas,

      I am actually trying to figure out how to test our custom View with integration tests - there are so many possibilities of objects that come through the view and get converted to XML using XStream that I'd like to test them in conjunction with our other integration tests to try and catch any errors in the XML caused by changes "further down".

      I guess one way to do it would be to mock up the DispatchServlet (we don't really want to test in container) and do it that way. Has anyone tried this?

      Another would be to change our Controller integration tests to run the Model we get back through the View and compare the result with the XML we expect. But then we're integration tests "down" and "up". Is that really bad?!!

      cheers,

      David

      Comment


      • #4
        David,

        I would be curious to know if/how you solved this?

        Rgrds, T.

        Comment


        • #5
          Not yet!

          Any ideas?

          cheers,

          David

          Comment


          • #6
            Why not move the XML generation into a POJO and unit test that POJO with all possible objects. Then your view is actually doing nothing but delegating to a POJO.

            Not knocking the use of integration tests but your question sounds like "we need confidence this bit of logic works", not "we need to make sure these talk together as expected", hence, unit test

            Comment

            Working...
            X