I am running into an issue while mocking the autowired component of a mvc controller. Here is my code, I am on Jmockit 1.28
@RunWith(SpringJUnit4ClassRunner.class)
@WebMvcTest(value = SomeController.class, secure = false)
public class SomeControllerUTest {
@BeforeClass
public static void applySpringIntegration() {
new BeanFactoryMockUp();
}
@Before
public void setup() throws Exception {
mockMvc = MockMvcBuilders.standaloneSetup(someController).build();
}
MockMvc mockMvc;
@Injectable
private DepServiceImpl depService;
@Tested(availableDuringSetup = true,fullyInitialized = true)
private SomeController someController;
@Test
public void testSomeBehavior() throws Exception {
BeanFactory beanFactory = new DefaultListableBeanFactory();
DepService service = (DepServiceImpl) beanFactory.getBean("depService");
assertSame(mlService, service);
}
}
Seeing the following error while running mvn test
Tests in error: com.test.SomeControllerUTest: Unable to find class file for org.springframework.beans.factory.support.$Subclass_AbstractBeanFactory