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.