Loading ...
Sorry, an error occurred while loading the content.

How to use HttpUnit n JsUnit

Expand Messages
  • Shrikant K.S
    Hi All, I am facing a problem while testing a JSP page which contains some Javascript code.I am using httpunit for testing. Here is my test method:
    Message 1 of 47 , Jun 14, 2005
    • 0 Attachment
      Hi All,
      I am facing a problem while testing a JSP page which
      contains some Javascript code.I am using httpunit for
      testing.

      Here is my test method:
      ======================================================================
      public void testGoodLogin() throws Exception {
      WebConversation conversation=null;
      WebResponse response=null;
      WebRequest request =null;
      String url =
      "http://localhost:8080/digite/Request?Key=login";
      try{
      conversation = new WebConversation();
      request = new GetMethodWebRequest( url );
      response = conversation.getResponse(request);
      response = conversation.getCurrentPage();
      WebForm form = response.getFormWithName("loginForm");
      form.setParameter("loginId","admin");
      form.setParameter("password","111111");
      response = form.submit();
      }
      catch(Exception e) {
      e.printStackTrace();
      fail("Failure::::"+ e);
      }
      }
      ======================================================================

      When we submit form after giving valid userId and
      password, the control should move to inbox_open page.
      When this login page reads a javascript function
      openFrameworkWindow(), i get an error like:

      com.meterware.httpunit.ScriptException: Script
      'openFrameworkWindow('/digite/Request?Key=framework_main&ContainedURL=inbox_open');'
      failed: org.mozilla.javascript.EcmaError: TypeError:
      Cannot set property "location" of undefined to
      "/digite/Request?Key=framework_main&ContainedURL=inbox_open"
      (httpunit#260)

      I found out that, httpunit doesnot support the
      javascript code present in the openFrameworkWindow()
      function. So now i am trying to use JsUnit for
      javascript testing.
      Now the problem is how to integrate HttpUnit and
      JsUnit ?

      Any help pls.

      Shrikant





      __________________________________________________________
      How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com
    • Jason Rogers
      ... In this case, yes. I want the fail-fast test case to run first. -- Jason Rogers I am crucified with Christ: nevertheless I live; yet not I, but Christ
      Message 47 of 47 , Jul 14 9:49 AM
      • 0 Attachment
        Kent Beck wrote:

        > Jason,
        >
        > It seems like you rely on the order of test execution to get quick
        > failure.
        > Is that correct?
        >
        In this case, yes. I want the "fail-fast" test case to run first.

        --
        Jason Rogers

        "I am crucified with Christ: nevertheless I live; yet not I,
        but Christ liveth in me: and the life which I now live in
        the flesh I live by the faith of the Son of God, who loved
        me, and gave himself for me."
        Galatians 2:20
      Your message has been successfully submitted and would be delivered to recipients shortly.