Hello everyone,I have a question with the coverage tests and the use of Mokito object
In my
test class
@Test
public
String savePessoaWithErro(){
when(result.hasErrors()).thenReturn(true);
String returnSavePessoa= appController.savePessoa(any(Pessoa.class), result, model);
/* when appController.savePessoa(any(Pessoa.class), result, model) , and result.hasErrors()=true, appController return pessoaadd */
AssertJUnit.assertEquals(returnSavePessoa,"pessoaadd");
return anyString();
}
In my controller class
@RequestMapping(value = { "/newpessoa" }, method = RequestMethod.POST)
public String savePessoa(@Valid Pessoa pessoa, BindingResult result, ModelMap model) {
if (result.hasErrors()) {
return PESSOAADD;
}
model.addAttribute(SUCCESS, pessoaService.save(pessoa));
return "pessoaRegistrationsuccess";
}
But jacoco,mark this as not covered and do not understand the reason.
someone would know the reason?
I appreciate your help and time
Thank you