• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using httpunit to test mandatory fields

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to use httpunit for automate testing of my web application.but so far i have never worked on the same.
as i want to check for mandatory fields..i need help regarding how to write a code for it
Again for eg. activity code cant be more than 6 digits..how to check that?
eg. how to access values from session....

any pointer would be appreciated


thanks ,
pravin
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you worked through the Cookbook and the Tutorial?

HttpUnit tests that web pages are OK with regard to their content; it does not deal with checking the output they send to the server. You could use it to submit a form that violates your contraints, and then have it check that you receive whatever error page you generate in those cases. The cookbook has a section on working with, and submitting, forms.
 
pranth pranth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thanks a lot for the quick reply.
i have gone through the cookbook and tutorial already but couldn't find the solution to my problem in it.
also in ur reply, u have stated that

HttpUnit tests that web pages are OK with regard to their content; it does not deal with checking the outputthey send to the server

.
what do u mean by mean by 'content' and 'output'. can u clarify with a simple example???
also, say i have a page that is used to create an activity. the form has fields like code, date etc.. in the form, say code is a mandatory field that needs to be filled. how to write the code in httpunit that tests if the field has some value in it and also how to validate if proper date format is given in the 'date' field??
thanks in advance.. waiting for ur reply...
 
pranth pranth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any pointers how to check reference table data is currect or not .actually these values are in session & not in form , once u select one of those , that value is assigned to some variable(property name in jsp) of form.
but when i try accessing value of that variable ,error is displayed that due to some reason it cant assign value to that variable.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Content is the page that gets served to the client; output is what gets submitted to the server.

HttpUnit is a client-side tool. It can check the contents of a HTML page that is served, e.g. it can get at the body element and verify that all the text and fields that should be there are in fact there.
You can not use it to check the validity of parameters during runtime. The closest you can get is to use it to set some parameters to faulty values, submit those to the server, and then check that the response that is returned is in fact an error page of some kind (which you need to have created first, of course).

To sum it up: HttpUnit doesn't attempt to do what you're trying to use it for (which is server-side validation). Server-side Frameworks like Stuts or JSF have facilities for that.
 
pranth pranth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey anybody of you know how to set a refernce table data.
EG. i has a drop down where values come from session. lets say 3 values r there. i set one of that to parameter of form . but it not at all setting values to it .


here is jsp code

where activityTypes has values from ref. table which r there in session , & once u select one of that ..it will be assigned to activityType.which is get stored to database.

i am using

Form.setParameter("activityType","new project");

but it not wrking at all
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused. JSP code is server-side code; HttpUnit is used for client-side code. When you say "it's not working at all", which of the two do you mean? If the page you're generating is not what you expect, post an example of what gets generated.
 
I once met a man from Nantucket. He had a tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic