@RunWith(SpringJUnit4ClassRunner.class)
public void ITest {
@Autowired
private EntityRepository dao;
@BeforeClass
public static void init() {
da
It looks to me that you are trying to populate DB before tests.
I would give a try to two options:
@Sql
@DatabaseSetup
and @DatabaseTearDown
which will do thing on DB you needI know that this does not answer how to inject bean in static @BeforeClass
but form code it looks it is solving your problem.
Update:
I recently run into same problem in my project and dug out this article which helped me and I think it is elegant way of dealing with this type of problem. You can extend SpringJUnit4ClassRunner
with listener which can do instance level setup with all your defined beans.