Dec 16th, 2010, 08:28 PM
Is Spring TransactionalJUnitTests actually integration test?
I am not sure if this is right place i post my question. I have a question about spring junit framework (extends AbstractTransactionalJUnit4SpringContextTests). is this test framework a integration test framework? because i just found that it can inject DAO and interact with Database. Thanks.
Dec 17th, 2010, 07:46 AM
It is support for Junit 4, so to do UNIT testing and not integration testing. If the unit you are testing is a DAO (a data access object, which DOES interact with the db - in fact it should do NOTHING else) you want to test its operations without real inpact on the db. Transactional tests let you simulate your operations in a transaction to test them against SQLExceptions and other DAO - related problems but be able to roll back at the end (even if the test is successful) so that the DB is not influenced by the tests.
It is a very valuable instrument to fully unit-test your persistence layer components without having to get a DB (even a test DB) dirty. If you are curious, you can learn how to use it in the official reference documentation.
Tags for this Thread