Mockito can only mock visible & non-final classes

While using Test Driven Development(TDD) we need to mock class/interface for the testing purpose. I recently came through this error “Mockito can only mock visible & non-final classes” while using mockito to mock an interface. Everything was looking fine, yet I was getting – “Mockito can only mock visible & non-final classes” error.

Finally I got rid of the error after some searching. It was due to use of early version of JDK8. So I updated my JDK to latest version and the error was gone.

So, please update your JDK to latest version to resolve the problem.

Thank you.

 

Regards,

Manohar Bhattarai

I am Manohar Bhattarai, a vivid java programmer. I am a keen Linux user. I currently boot Ubuntu Linux. I am a Free/Libre Open Source Software enthusiast.

Posted in Java, Test driven development Tagged with: , , ,

Leave a Reply