views:

31

answers:

3

I'm building a Spring web app and up until now all of my testing is using a browser.

This involves starting the server, opening a browser window and checking to see if accessing any of the pages causes an error.

This is starting to get repetitive and doesn't seem to be the most efficient way to do this.

Since the Junit jar file is already in my project, could it be used as an alternative to this browser testing and, if so, any tips on how to get started making JUnit simulate the act of opening a browser to access the web app?

+2  A: 

Take a look at Selenium. It allows you to script functional tests using JUnit or TestNG and execute them in a browser, automatically.

Bozho
+2  A: 

You can use the HTMLUnit extension to script to drive the web site from JUnit.

I used a while back and worked fine for thi site I was doing then.

see http://htmlunit.sourceforge.net/

Peter Tillemans
A: 

I suggest you to try the Robot Framework. This is an open source testing framework developed by engineers in Nokia Siemens Networks.

It is primarily built on python and the Selenium testing libraries. It also includes support for testing Java/J2EE server side code through Jython libraries. I personally use it in my work sometimes, and writing a test case is just as easy as describing an end-to-end flow through the use of Keywords (most of required ones are already inbuilt). You could go ahead and give this a shot if you find Selenium a li'l tough to work with. The Robot framework provides a fairly simple abstraction over raw selenium, coupled with the power to make Java/J2EE server-side calls too.

Regards,
Nagendra U M

Nagendra U M