Announcement Announcement Module
No announcement yet.
How to test the service layer? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to test the service layer?

    What is the best way (with using spring 2.0) to test the service layer?

    Currently I test my dao layer with the abstractTransactionalDataSourceSpringContextTests Class, in the same way as in the Spring PetClinic Sample application.

    This executes each test method in its own transaction, which is automatically
    rolled back by default, so I don't need teardown or cleanup actions after each test.

    But what is a nice way to test my service layer? Do I need to use easymock? Or can I use the abstractTransactionalDataSourceSpringContextTests again?
    Last edited by springzilla; Sep 11th, 2007, 10:50 AM.

  • #2
    It depends how you are wanting to test the service layer. Are you wanting to use mocks and/or stubs (which would probably be the best idea) or integration tests (so you're testing with the real collaborators). If it's the latter then you can use the same class you were using before. If you are using mocks you can just set this up yourself. There is an article from the interface21 team blog here that might be useful. It might also be useful to have a look at the unit tests that ship with spring.