Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (120 points)

I am mocking a service layer and stubbing one of the method but doReturn doesnt return the mocked value. Bellow is my code, what i am doing wrong

public class Service
    Dao dao;
   public int doSomething(){
      return 2;

public class Test{

   Service instanceOfService;

  public void testMethod(){

   Service mockedService = Mockito.spy(instanceOfService)
   Assert.assertEquals(4, mockedService.doSomething());


Please log in or register to answer this question.

Related questions

Browse Categories