I am trying to write a moct test for java controller. This is working fine when I am running this as a junit but this getting failed when i am running in build.
Here is my test class.
@WebAppConfiguration
@RunWith(PowerMockRunner.class)
public class myTestClass {
private MockMvc mockMvc;
@Mock
MyActionScript myActionScript; // It is failing here
@Mock
MyBaseClass myBaseClass; // It is failing here
@Mock
MyControllerClass myControllerClass;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(MyControllerClass).build();
}
@Test
@PrepareForTest({TestClass.class})
public void testmyMethod()throws Throwable{
//SOme code
}
}
Here the problem is as soon as I am trying to mock my actionscript class or myBaseClass this is getting failed.
Here is my controller class
@Controller
public class ReportsController extends BaseController {
@RequestMapping(value = "/someurl", method = RequestMethod.POST, consumes = "application/json")
public @ResponseBody somePojo methodList(@RequestBody somePojo requestObj) throws Exception {
somePojo response = (somePojo) this.execute(requestObj,SOME_CONSTANT);
return response;
}
}
My controller class extending to the some abstract class.
Here i my myBaseClass
@Controller
public abstract class myBaseClass extends myActionScript {
//Some Code and some methods
}
Please let me know if you required any thing else.
Aucun commentaire:
Enregistrer un commentaire