Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
@Mock annotation from easymock api does not work for two fields of the same type. #755
if we have a simple test class like below
then both assertions fail. We noticed that whenever two fields of the same type are annotated with
If we remove first one or change to
then it works as expected. We encountered that when migrating from
jdk7 + easymock 3.3 + powermock 1.6.1
jdk8 + easymock 3.4 + powermock 1.6.6
OS is: Linux *** 4.4.0-62-generic 83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Does any workaround exist besides replacing annotation with
UPDATE: it seems to be similar to #668 but I checked and it works for a third field as long as it has different type (I checked for 3 fields - 2 x String and 1 x Integer - and strings do not work but integer does).
I've found out that org.powermock.api.easymock.annotation.Mock has a new property called fieldName that solves the problem. However with that additional configuration:
What makes you introduce that feature? Is it documented somewhere?
I've checked and it does not change anything. Moreover I almost changed all places in our codes but reached one with org.powermock.api.easymock.annotation.MockNice annotation that is also affected but does not have fieldName to be set.