I do a test for the data removal method.
//MessageController.java @RequestMapping( value = "api/message/{id}", method = RequestMethod.DELETE) public ResponseEntity<?> deleteMessage(@PathVariable Long id) { if (!messageService.delete(id)) { throw new DataNotFoundException("Data with id=" + id + " not found."); } return new ResponseEntity<>(HttpStatus.OK); } //messageServiceImpl.java @Override public boolean delete(Long id) { Message message = messageRepository.findOne(id); if (message == null) { throw new DataNotFoundException("Data with id=" + id + " not found."); } messageRepository.delete(id); return true; } The method itself works, records are deleted, I do a test for the service.
//messageServiceImplTest.java @Mock private MessageService messageService; @InjectMocks MessageServiceImp messageServiceImp; public void delete() throws Exception { //prepare when(messageService.delete(ID)).thenReturn(true); //testing boolean testMessage = messageService.delete(ID); //validate verify(messageService).delete(ID); } And I get the error java.lang.Exception: No tests found matching Method delete
There is a method, what is the matter?