@RunWith(SpringJUnit4ClassRunner.class)
public void ITest {
@Autowired
private EntityRepository dao;
@BeforeClass
public static void init() {
da
With Junit 5 you can do this (@BeforeAll instead of @BeforeClass)
public void ITest {
@Autowired
private EntityRepository dao;
@BeforeAll
public static void init(@Autowired EntityRepository dao) {
dao.save(initialEntity); //possible now as autowired function parameter is used
}
}
By leaving the field it means it can be used in other tests