Having the attached example project test.zip (unzip and run gradlew test -i), you get an error Attempted to record expectation on unmockable method.
The String@Injectable is necessary to satisfy the Logger constructor argument. But as far as I understand the Injectable JavaDoc, no other instances of String should be affected in any way. Yet this error occurs while actually no expectation for this method is recorded, its return value is just used as argument matcher.
Workaround: Do the getBytes() call before the Expectations block
The text was updated successfully, but these errors were encountered:
If you look at the provided MVCE together with my description, you will see that I do not even try to record an expectation on a String. I just use an unmocked String instance in an expectation as parameter for or as return value for some other expectation.
I guess this has to do with #344. If in the provided test-case I change @Injectable to @Injectable("") (which is the default value anyway), it still fails with the same error. If I change it to @Injectable("f") it suddenly works fine. @Injectable String nameForLogger = "f"; again fails with the error, @Injectable final String nameForLogger = "f"; works fine.
So I'd say somehow JMockit has a special treatment for the empty string which is not good for it.
There is indeed a bug here, that I just noted after some experimentation. The real issue is that an "@Injectable String" field seems to be getting partially mocked, when it should not be mocked at all. With a test method parameter, there is no problem. So, it's probably a bug specific to mock fields.
Having the attached example project test.zip (unzip and run
gradlew test -i
), you get an errorAttempted to record expectation on unmockable method
.The
String
@Injectable
is necessary to satisfy theLogger
constructor argument. But as far as I understand theInjectable
JavaDoc, no other instances ofString
should be affected in any way. Yet this error occurs while actually no expectation for this method is recorded, its return value is just used as argument matcher.Workaround: Do the
getBytes()
call before theExpectations
blockThe text was updated successfully, but these errors were encountered: