This question was asked before Using Autowired in a TestExecutionListener class for BeforeClass junit however it wasn't answered. I am facing the same problem but haven't figured out the solution
Example: I am getting null mapper.
public class CustomExecutionListener extends AbstractTestExecutionListener {
@Autowired
private Mapper mapper;
@Override
public void beforeTestClass(TestContext testContext) {}
... some code...
}
Test Class: Note: AppConfig contains the Mapper Bean defined.
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners(listeners = {DependencyInjectionTestExecutionListener.class, CustomExecutionListener.class})
@ContextConfiguration(classes = {AppConfig.class})
public class AccountControllerTest {
....
}