Menu

Structuring HTTPUnit tests

Help
2003-03-19
2003-04-25
  • Mitch Christensen

    Hey,

    Does anyone have suggestions the best way to structure HTTUnit tests for an entire web application?

    I am currently validating our webapp using one java class per web page.  Each java class has a public static validate() method that returns a boolean.  The validate() method requests the WebResponse for it's page, and the walks through a set of validations using this WebResponse.  If any of the validations fail, validate() immediately return false.  If all validations succeed, validate() may optionally invoke the validate() method on other (subordinate) pages, and then return.

    With this approach, I have one .class file per validated web page, one JUnit TestCase and one Ant script that starts it all off.  It just seems that should might a better way to integrate with/leverage the JUnit TestCase features (assertXXX(), etc.).

    I've never actually come across documentation describing how to structure HTTUnit tests, so any suggestions would be greatly appreciated.

    Thanks,
    -Mitch

    Given my model, the following typical function call graph applies,

    ant unit-test
      <java classname="test.UnitTest".../>
        UnitTest.validate()  // this is the JUnit TestCase
        LoginPage.validate()
          NewUserPage.validate()
          UserNameSearchPage.validate()
            SearchResultsPage.validate()
          SSNSearchPage.validate()
            SearchResultsPage.validate()
          RemoveUserPage.validate()
        LogoffPage.validate()

     
    • David Rutter

      David Rutter - 2003-04-25

      I found that for large or complex web applications,
      that it was easier to structure the test steps as xml, and to drive httpunit using the xml test steps.

      See http://sourceforge.net/projects/xmltestsuite.
      Canoo is another example of driving httpunit using xml.

       

Log in to post a comment.

MongoDB Logo MongoDB