Execute Junit Test Case on Real Device in Android Studio

Hello,

I have a Junit test case in my MicroEJ project which validates the foundation library.
I’m using MicroejTestEngine in gradle testing task.I want to execute it on real device but I don’t know the steps how to execute it on real device as we do similarly in Android.

I am referring the link https://docs.microej.com/en/latest/ApplicationDeveloperGuide/testsuiteEngine.html to find some useful information regarding the same but no luck.

Can you please guide me on where I’m doing wrong OR are there other steps to execute Junit tests on real device?

Thanks.

Hi @nitin123 ,

Could you please change the following parameters in your .gradle.kts from:
microej.useMicroejTestEngine(this)

to:

microej.useMicroejTestEngine(this, TestTarget.EMB)

You could also check the documentation for further help on the topic: Test a Project — MicroEJ Documentation

Have a nice day!
Gaëtan for MicroEJ

@gaetan.harel, Thanks for your reply. I tried to replace microej.useMicroejTestEngine(this, TestTarget.EMB) in my .gradle.kts but this did not work. I followed the steps from the link you have provided https://docs.microej.com/en/latest/SDK6UserGuide/testProject.html#test-on-device but I’m getting issue while executing the step given in the documentation in the above link: ./gradlew execTool --name=serialToSocketTransmitter
–toolProperty=serail.to.socket.comm.port=“COM8”
–toolProperty=serail.to.socket.comm.baudrate=“115200”
–toolProperty=serail.to.socket.server.port=“5555”
–console plain

and I have highlighted that issue in the attached screenshot below:
Note: My-project-lib is the module in my project where gradle dependency ej.api:event:2.1.0 is used.

Also I don’t understand the one of the step from the document link which is :
Have a device connected to your workstation both for programming the Executable and getting the output traces. Consult your VEE Port specific documentation for setup.

Can you please tell me more about this step and how to achieve or verify it if it is already done in my case?

Hi @nitin123 ,

The module you are looking for is not in the Central Repository or the Developer Repository. Why are you looking for this specific version 2.1.0 of the event library?

Regarding connecting your device to your computer for flashing, it will indeed depend on the specific hardware. Most of the time the VEE port explains how to connect the device to program its flash memory and how to get the traces. What is the VEE port in question? Depending on the device you could have a probe and UART link detected when connecting the device to your PC (most of the time using USB).

Have a nice day!
Gaëtan