I'm new to unitils(built in dbunit) and spring. At the new place I'm working I can see that some of the testing is with spring and others using unitils/dbunit without spring.
There is a push to use spring so I've been trying to merge the following functionality.
Spring tests using:
@RunWith(SpringJUnit4ClassRunner.class )
@ContextConfiguration(locations = { "classpath:spring-dev.xml" })
public class x(){
@Autowired
private ProfileDao profileDao;
@Test
@Rollback
@Transactional
public void shouldRetrieveProfileByUserNumber() {
Profile profile = profileDao.retrieveProfile("u1", "0000003861", null);
assertThat(profile.getUserNumber(), is("0000003861"));
}
This class has the @Autowired ProfileDao, which works when using the @RunWith(SpringJUnit4ClassRunner.class ).
Unitils tests using:
@RunWith(UnitilsJUnit4TestClassRunner.class)
@DataSet("WEB_SERVICE_DATASET.xml")
public class ServiceExceptionTest {}
Which correctly loads the database etc when run.
What I'm trying to achieve is to combine these so that I can "Unitil'ise" my class with the @RunWith(UnitilsJUnit4TestClassRunner.class) annotation but also make use of spring in the normal way as in the previous class.
Problem is I can't seem to unitilise my class whilst using the spring version as they're both JUnit4ClassRunner extensions.
I've tried a variety of variations but have not been able to get any to work.
Can anyone advise on a decent way of doing this?
Thanks