mardi 12 février 2019

Testing a function which has multiple autowired classes in a nested manner using Mockito

Here I want to test method1. I wanted to implement it using Mocks And InjectMocks but using the class B as mock, it returns null exception.

 class A {
     @Autowired
     private B b;

     public method1()
       {
         return b.method2(); 
       }
     }

class B{
     @Autowired
     private C c;

    public method2(){
       return C.method3();
     }
    }

Aucun commentaire:

Enregistrer un commentaire