Well, you have to be careful about this: by default, you cannot mock final classes (e.g. String). This is a known limitation in structure.
Your example is not suitable for me with the corresponding error message:
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class java.lang.String
Mockito cannot mock/spy following:
- final classes
- anonymous classes
- primitive types
at Test.testShouldFail(Test.java:6)
...
, , . IDE ? Mockito ? ?
, PowerMock, . Mockito .
, String java.lang, , , VM ( , ). , (.. -) (, , - java.*). .