Sure Bruce.
I tried changing mockito and JUnit versions on both sides from JUnit 4.8 up to to 4.10, and Mockito 1.8.5 and 1.9.0-rc1. None of those changes made a difference, and as far as I can tell, both IntelliJ and Ant were aligned for every attempt.
The current configuration is what I started with: JUnit 4.8 and Mockito 1.8.5. Ant version was always 1.8.2.
The ant test target is pretty boilerplate:
<target name="test" depends="compile,compile.tests" description="test all">
<mkdir dir="${test.dir}/reports/"/>
<junit printsummary="true" showoutput="true" failureproperty="junit.failure">
<formatter type="brief" usefile="false"/>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest todir="${test.dir}/reports/">
<fileset dir="${test.dir}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
<classpath>
<pathelement path="${out.dir}/classes"/>
<pathelement path="${out.test.dir}"/>
<fileset dir="${test.libs.dir}" includes="*.jar"/>
<fileset dir="${external.libs.dir}" includes="*.jar"/>
<path refid="android.target.classpath"/>
</classpath>
</junit>
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
</target>
The test in question was failing on something a lot like this in a @Before method:
resultProcessor = new ApiResultProcessor(){
@Override
public void handleSuccess(Object resultObject) {
}
};
};
spiedProcessor = spy(resultProcessor);
It failed on the line that attempted to spy on resultProcessor, with the
error:
"Mockito cannot mock this class: class
com.livingsocial.android.api.ResultProcessorTest$1. Mockito can only mock visible & non-final classes."
I overlooked the "$1" -- that's the anonymous class. The work-around was to create an inner class, which *has* to be declared public rather than default visibility:
public class TestResultProcessor extends ApiResultProcessor {
@Override
public void handleSuccess(Object resultObject) {
}
}
Then the setup method can use:
resultProcessor = new TestResultProcessor();
spiedProcessor = spy(resultProcessor);
Hope that helps.
Dave