Mockito
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
I have controller class, abcRepository, abcService, abcServiceImplementation. abcRepository extends JPARepository. I have autowired abcService in controller class.
Now how can I use mockito to test my rest APIs with above structure.
Till now I tried and written test class with @Mock on AbcService and @InjectMock on controller, but while running getting error as controller as null.
What is the correct procedure to test rest api with above structure?
Please guide.
I have controller class, abcRepository, abcService, abcServiceImplementation. abcRepository extends JPARepository. I have autowired abcService in controller class.
Now how can I use mockito to test my rest APIs with above structure.
Till now I tried and written test class with @Mock on AbcService and @InjectMock on controller, but while running getting error as controller as null.
What is the correct procedure to test rest api with above structure?
Please guide.
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hello, welcome to the Ranch!
It's hard to get a grip on what you have got there. Perhaps an example would help?
Can you show us what you've got so far, what it is exactly you're trying to achieve, and exactly what problem you are facing?
It's hard to get a grip on what you have got there. Perhaps an example would help?
Can you show us what you've got so far, what it is exactly you're trying to achieve, and exactly what problem you are facing?
Tim Driven Development | Test until the fear goes away
Tej De
Greenhorn
Posts: 2
posted 9 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
I have
1. Controller class abc.
2. AbcRepository which extend JPAREPOSITORY.
3. Interface as abcService to have CRUD operations.
4. Class AbcServiceImplementation to implement abcService, in that I have used for eg abcRepository.saveandflush().
In controller class, I have autowired abcService, and written APIs to perform crud operations.
All APIs are working.
How can I use mockito to test my rest APIs with above structure.
I am new to mockito. Please guide.
Thanks.
I have
1. Controller class abc.
2. AbcRepository which extend JPAREPOSITORY.
3. Interface as abcService to have CRUD operations.
4. Class AbcServiceImplementation to implement abcService, in that I have used for eg abcRepository.saveandflush().
In controller class, I have autowired abcService, and written APIs to perform crud operations.
All APIs are working.
How can I use mockito to test my rest APIs with above structure.
I am new to mockito. Please guide.
Thanks.
| Oh the stink of it! Smell my tiny ad! Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |









