jWebUnit

Jasper
0 0
Read Time:43 Second

During my current project, i encountered jWebUnit, a unittesting framework based on jUnit and HttpUnit. Old news for some, new for me.
Since we already had some posts on jUnit and HttpUnit, i thought this might be of interest.
An example of its conciseness (as found on the jWebUnit homepage):

Old code (jUnit & HttpUnit):

   public void testSearch() throws Exception {
      WebConversation wc = new WebConversation();
      WebResponse resp = wc.getResponse( "http://www.google.com");
      WebForm form = resp.getForms()[0];
      form.setParameter("q", "HttpUnit");
      WebRequest req = form.getRequest("btnG");
      resp = wc.getResponse(req);
      assertNotNull(resp.getLinkWith("HttpUnit"));
      resp = resp.getLinkWith("HttpUnit").click();
      assertEquals(resp.getTitle(), "HttpUnit");
      assertNotNull(resp.getLinkWith("User's Manual"));
   }

New code, using jWebUnit:

   public void setUp() {
      getTestContext().setBaseUrl("http://www.google.com");
   }

   public void testSearch() {
      beginAt("/");
      setFormElement("q", "httpunit");
      submit("btnG");
      clickLinkWithText("HttpUnit");
      assertTitleEquals("HttpUnit");
      assertLinkPresentWithText("User's Manual");
   }

For more information, see http://jwebunit.sourceforge.net/

About Post Author

Jasper

Consultant at AMIS
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
Next Post

Table FUNctions: select a graph in SQL

You may seen some enthousiastic ramblings on Table Functions in earlier posts I have written. This is another one. With approximately 50 lines of code, you can select crude graphs for any query. For example, a graph that indicates the total salary sum for the three departments in the SCOTT […]
%d bloggers like this: