I've started a project up at https://github.com/mikeycmccarthy/spring-liquibase-test to make DAO type testing easier in a context where Liquibase is being used. The class itself is very simple and looks like the below (hopefully the config classes are explanatory).
This class would simply get extended for each DAO type test. What I am struggling with at the moment is best way of getting the class under test into the application context. If you look in the test directory (https://github.com/mikeycmccarthy/sp...mikeycmccarthy) I'm using the Repository annotation on the class under test and that field has a Resource annotation above it in the test (ignore the new constructor).Code:@ContextConfiguration(classes = {StandaloneDataSourceConfig.class, TransactionManagerConfig.class, LiquibaseConfig.class}, loader = AnnotationConfigContextLoader.class) public class AbstractTransactionalLiquibaseTest extends AbstractTransactionalJUnit4SpringContextTests { }
If this test class is going to be useful it'd have to be agnostic of package names and the type of bean configuration (XML,annotations being used). Using Spring 3.1 do people think the best way is to simply add more bean definitions from within the test class? I was thinking I might make my test class in this case context annotation driven and supply the package name such that it sees the class under test.
Many thanks for any pointers, the 3.1 stuff is pretty new to me (but looks cool!)


Reply With Quote