java - EasyMock and Ibatis -


in dao layer doing database work calling stored procedures. wondering has been successful in testing dao layer using easymock?

thanks damien

i that's impossible. there's no way assert (with easymock or other mocking framework) dao called stored procedure, verify did etc.

the thing can dao + easymock mock/stub dao, you're not testing dao instead collaborator acting on dao (typically kind of controller if we're speaking mvc).

to integration test of dao/storedprocedures recommend dbunit:

  1. put testdata database (if you're using junit in @before method)
  2. call dao method under test
  3. if method returned result, compare expected data in (1)
  4. if method performed inserts/updates, call "read method" , compare result (1)

in case dao provides crud business entity can test each operation of dao:

  • testload - load db , compare (1)
  • testinsert - insert new entity db reload , compare
  • testupdate - modify existing entity, save db , reload/compare
  • testdelete - delete entity (1), try load , assert fails (also check nothing else deleted)

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -