3

I want to write some functional tests for a java servlet and I want to make sure it works with all the filters and other random java web stuff that might interfere with the servlet. Is there a nice way to do this in java?

I noticed the play framework has a really nice way of doing functional tests.

import play.test.*;
import play.mvc.*;
import play.mvc.Http.*;
import org.junit.*;

public class ApplicationTest extends FunctionalTest {

    @Test
    public void testTheHomePage() {
        Response response = GET("/");
        assertStatus(200, response);
    }

}

http://www.playframework.org/documentation/1.0/test

Something like that would be great but I guess I'm getting my hopes up. :)

benmmurphy
  • 2,503
  • 1
  • 20
  • 30

3 Answers3

1

Selenium is one option. It has the ability to export the tests to JUnit 3 or 4.

jefflunt
  • 33,527
  • 7
  • 88
  • 126
1

The Apache Cactus tool extends JUnit and allows you to test server-side code. For example, it provides a ServletTestCase that allows you to run code as it would in the Servlet, FilterTestCase, JspTestCase, etc. - see the Features page for more details. They also reference the HttpUnit project (which hasn't had much recent activity).

Tai Squared
  • 12,273
  • 24
  • 72
  • 82
  • that's kind of what i want but i would like it be much more simpler. i don't want to deploy wars. i would just like to extend a TestClass and maybe specify a web.xml descriptor and then everything should just work. – benmmurphy Jun 16 '11 at 08:58
0

I advice you to use Selenium + FluentLenium.

FluentLenium is a java framework that ease the use of Selenium.

It target numerous web browsers.