unsafe_where_true
unsafe_where_true

Reputation: 6300

Testing a GWT/spring application on service level

I recently managed to convince my mates in the project that we need testing (!). Due to the highly dynamic and flexible structure of our web application, with behavior depending of lots of parameters and permission relationships, they had rejected testing altogether, for the usual reasons (time consuming, test maintenance, etc.).

We will introduce testing at the service layer:

Web Browser -> GWT/RPC -> GWT Servlet -> RMI -> SessionEJB -> RMI -> Spring beans

Thus after the GWT Servlet. Do people recommend to use junit? Or are there other test frameworks better suited? Any other general suggestions? Thanks

Upvotes: 1

Views: 460

Answers (3)

GeertPt
GeertPt

Reputation: 17854

You can indeed use plain JUnit or TestNG with a mock framework to test your SessionEJB and individual Spring beans in isolation, i.e. proper Unit testing.

But since there is already a lot of code written, you'll probably find more bugs with less code using system testing or integration testing, i.e. test your complete SessionEJB and spring beans roundtrip in a test application context, with even a real database behind.

For integration and system testing, you can use DBUnit to have a fixture of test data in a database. And Spring also has a lot of test support utils. All of this things work with both JUnit and TestNG.

Upvotes: 1

Stefan Gloutnikov
Stefan Gloutnikov

Reputation: 448

As for a testing framework, I highly recommend TestNG (http://testng.org), with Mockito (code.google.com/p/mockito/). I love using both due to their ease of use. @DataProvider in TestNG helps me a lot, as well as other annotations for setting up a test before/after running. I was using JUnit before until I met TestNG at work and don't think I'll be going back anytime soon :)

Check them out, TestNG is definitely picking up some steam and gaining reputation.

Upvotes: 0

pedorro
pedorro

Reputation: 3327

You should be able to JUnit your Servlets & EJBs. I suggest using some kind of mock framework (e.g. EasyMock) for your servlet context and if you are using any kind of JNDI resource or dependency injection.

Upvotes: 0

Related Questions