Use Of Unit test Mockito Java library in MicroEJ applications

I’m new to MicroEJ and we are currently using your JUnit module to implement Unit Tests for our libraries (build-microej-javalib build-type) that we can run in simulation.

But to advance test Implementation, We want to use Mockito library in MicroEJ Studio. We tried to use the related dependency “” in the module’s (build-microej-javalib build-type) module.ivy file but It’s showing an error as

Error : impossible to resolve dependencies:
Cause : resolve failed: unresolved dependency: org.mockito#mockito-core;[3.5.11-RC,3.5.12-RC[: not found. Any idea where I making mistake or something is missing from Implementation perspective.

Hi,

The Mockito library is probably not available in the module repositories you are using. It can be fetched from the Maven central repository: Maven Central: org.mockito:mockito-core
So you must install this module in your module repository or declare the Maven Central repository in your Ivy settings file (by default it is at <USER_HOME>/.microej/microej-ivysettings-5.4.xml), by adding the following resolver:

<ibiblio name="maven2" m2compatible="true"/>

Hey @tdelhomenie ,
Thanks for your help. I was able to fetch and use Mockito in the test class. But still, I’m getting errors while running or building the project and it looks like MicroEJ SDK runs the Junit test on MicroEJTest Suite (MicroEJ VM), and from my understanding, Mockito library is purely a Java-based library. To resolve this issue I followed the existing thread on the forum https://forum.microej.com/t/unit-tests-with-mockito/957 and I have added these two lines in projects module.Ivy file to run the test on standard J2SE VM <ea:plugin org=“com.is2t.easyant.plugins” module=“microej-junit” revision=“1.0.+”/>
<ea:property name=“skip.com.is2t.easyant.plugins#microej-testsuite;[3.3.0-RC0,4.0.0-RC0[” value=“true” />.

Console log error message :
"Found an error when building Calculator
Where:

File : D:\Installed software\rcp\configuration\org.eclipse.osgi\9\data\repositories\microej-build-repository\com\is2t\easyant\plugins\microej-testsuite\4.2.0\microej-testsuite-4.2.0.ant
Line : 322 column : 98

  • Problem Report:"

Dependency added to run tests on J2SE VM:

<info organisation="Calculator" module="Calculator" status="integration" revision="0.1.0">
	<ea:build organisation="com.is2t.easyant.buildtypes" module="build-microej-javalib" revision="6.2.+">
		<ea:property name="test.run.includes.pattern" value="**/_AllTests_*.class"/>
	<ea:plugin org="com.is2t.easyant.plugins" module="microej-junit" revision="2.0.0"/> **
          <ea:property name="skip.com.is2t.easyant.plugins#microej-testsuite;[5.6.0-RC0,5.6.0-RC0[" 
          value="true" />
	</ea:build>
</info>

I cannot see the full error message in your post (after the Problem Report).

As mentioned in the post Unit tests with Mockito - #2 by tdelhomenie the version of the plugin to skip must match with the version used by the build type (com.is2t.easyant.buildtypes:build-microej-javalib:6.2.+). For this build type version, the microej-testsuite version is 4.2.+, so it should be:

<ea:property name="skip.com.is2t.easyant.plugins#microej-testsuite;4.2.+" value="true" />

You should see a trace saying that the plugin has been skipped.