3
votes

I'm currently unit testing some GWT RPC services with unit tests extending GWTTestCase. All the testcases basically rely on test data being available in the persisted store. I cant set this up from the GWTTestCase since GWT complains about the hibernate objects not being serializable(i suppose the entire class gets compiled into javascript, and not just the actual testcase).

I could obviously just insert it into the database and leave it, but I don't really like that solution.

Currently, I added some methods to the RPC services that basically sets up the service for testing, and one that removes everything. Again, I think this is a bad solution. I would love to be able to use the normal @BeforeClass and @AfterClass annotations I use when unittesting the domain model. Can anybody share their experiences with GWTTestCase GWT RPC implementations and how you populate you persistent store with data before the testcases gets run.

-Daniel

1
Being more than a year since you asked the question, how have you solved your problem (if solved at all)? - homaxto
I ended up wrapping the relevant code in DAOs, mocked those in the GWTTestCase and then did normal unit, integration and acceptance testing on those DAOs (since they happily can live outside the GWT bubble) - JustDanyul

1 Answers

0
votes

What forces you to use GWTTestCase to test RPC services ? Can't you just directly invoke the RPC methods on the RPC implementation class ? You only need to mock the HTTPRequest object. So you can just use plain JUnit tests instead of the slow to start GWTTestCase.