I'd like to write a JUnit Test for a Dao class. The dao do not need any save method as it is reading only some data.
The Test is using HSQLDB and I need to insert some test data first. As I do not want to write code only to make the test running I extend the DaoImpl class to have a save method.
Now I'd like to @Autowire the DaoTestImpl class but getting a No qualifying bean of type […] found for dependency error.
My setup in src/main looks like this:
interface Dao ...
@Repository("Dao") class DaoImpl implements Dao ...
And for the test in src/test I have the new class:
@Repository("DaoTestImpl") class DaoTestImpl extends DaoImpl
In the JUnit Test I'm using
@Autowired
@Qualifier("DaoTestImpl")
private DaoTestImpl daoTestImpl;
Is there something wrong when autowireing a Bean which extends another Bean? If the DaoTestImpl class is implementing the interface Spring will find the proper Bean. But in this case I cannot test the DaoImpl class.