I am testing my business service with TestNG, mockito unit tests in spring boot application.
My annotation to service look like
@Service
@Transactional
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface MyService{}
My TestApp looks like
@SpringBootApplication
public class TestApp
{ .... }
MyTestClass looks like
@ContextConfiguration(classes = { TestApp.class })
class MyTestClass
{
@Mock ....
@InjectMocks .....
@BeforeMethod
public void initMock()
{
MockitoAnnotations.initMocks(this);
}
}
If I don't use @Target(ElementType.TYPE), @Retention(RetentionPolicy.RUNTIME), @Inherited these annotations then my mock DAO calls in test works fine
BUT when I use above annotations then mock DAO calls does not works.
- Why this is not working ?
- What would be the solution over it ?
Your response is appreciated !!
Aucun commentaire:
Enregistrer un commentaire