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:
- put testdata database (if you're using junit in @before method)
- call dao method under test
- if method returned result, compare expected data in (1)
- 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 , comparetestupdate
- modify existing entity, save db , reload/comparetestdelete
- delete entity (1), try load , assert fails (also check nothing else deleted)
Comments
Post a Comment