Failed to connect to / from Instrumentation tests

I am using Android Studio + JUnit + Appium 7.3.0 on Mac OS Catalina

Have tests in folder ‘test’ and ‘androidTest’, as I need to run both unit and instrumental tests I moved instrumental tests to androidTest folder and set up configuration for it. But now I can’t run my tests as following error appear:

Connected to process 13459 on device ‘…’

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Original error: Failed to connect to / … … Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused) at

Appium server log has no new lines in it, so latest entry is [Appium] Appium REST http interface listener started on

If I run same test but put it in ‘test’ folder it runs in Appium as expected (but that folder is for unit tests and also does not fit to my tests many of which throw this error “No instrumentation registered! Must run under a registering instrumentation.” So that’s why I moved it to androidTest folder. So I only see configuration difference so far. Anyway I did not find solution yet, please help.

Instrumentation class - androidx.test.runner.AndroidJUnitRunner.


DesiredCapabilities caps =;

    caps.setCapability(MobileCapabilityType.DEVICE_NAME, "...");
    caps.setCapability(MobileCapabilityType.BROWSER_NAME, "");
    caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.0");
    caps.setCapability(MobileCapabilityType.APP, "....apk");