INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

The basics of using JUNIT

The basics of using JUNIT

(OP)
I am a novice with Java and the tools associated with it.  I am trying to write a test class to just verify links, buttons and dropdown menus on a web page but cannot find any useful documentation explaining how to run this with JUnit.  

Any assistance would be greatly appreciated.

Thanks to all in advance.

Scott H.

RE: The basics of using JUNIT

generally speaking you wont use junit for testing a webpage.

junit is used to test your java classes and methods to compaire what you expect the outcome of the method to be and what it actually is.

if your testing a gui or webpage then its really a hands on approach that your gona have to do.

as far as i know jbuilder has a gui testing utility (but i doubt that will test a webpage), i dont know the name of it unfortunitly and i dont know if its any good. jbuilder isnt free though.

but there is a more round about way of testing a webpage using junit and this may not work all the time with dynamic content.

if you need to test links i would suggest you have a look at creating your own java based web browser. all you need is to get the basic code that opens the page and gathers the data from the page. (i cant remember the api unfortunitly but someelse might) after that its just a matter of reading that data to see does it contain any errors i.e. 404, 403 etc (i.e. its an invalid link) and the info you'd expect on the webpage i.e. is it the right page, does it contain "sum text"

so all you'd do is after the page is generated, you would load the html page in your junit test and parse the information, read the links and do the above stuff. so that procedure can be done automatically.

this can be done then for your button's links and similar for your drop down menus, depending of course the content of the menus.

RE: The basics of using JUNIT

(OP)
Thanks Dexter.  I'm tasked with creating some basic JUNIT testing for behind the scenes data now, not necessarily the web page GUI.  Is there somewhere I can just find a basic JUNIT setup that I can adapt to my current testing and then dive in from there?

RE: The basics of using JUNIT

this is a decent resource for junit.
http://junit.sourceforge.net/

essentially when your using junit you design the test methods along side the real methods. so you gradually build the methods along side each other. this may seem like a lot of work when you first start using junit but its worth it.

remember, junit can only really test methods that return something. you might think, ah nuts i cant test that method cus its not returning something but if that method is being used by another method, that returns a value and its outcome is as expected then you can assume that both are correct. however your still best off to initally create the method to return something and when you know it works change it back to its original state. i hope thats not too confusing.

what i would suggest you should do is get an ide called eclipse as that has a built in junit test suite that will display the results in an easy to use gui. for recording purposes i would also suggest you have a look into "ant". its a scripting language, which looks exactly like xml. it has junit addons that will create webpages with the results of your junit tests so you can post them for other programmers to look through and also you can now save the results.

you can get ant here.
http://ant.apache.org/bindownload.cgi

here is the stuff for the junit task in ant
http://ant.apache.org/manual/OptionalTasks/junit.html

you can get eclipse here
http://www.eclipse.org/downloads/index.php



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close