Using MockK for Android UI tests should function identically on any Android 9+ emulator and a physical device.
On the simulator, tests that utilize MockK functions (as part of the test class file) typically fail at random with the error message:
Instruments run failed due to a “Process Crashed” error.
This so-called crash may occur prior to the beginning of the first test or in the midst of a test sequence. Regardless of the sequence of the tests, it is largely random.
In rare instances, there are no crashes and all tests succeed. However, it is also too arbitrary here.
In the majority of cases, the cause of the accident will be recorded in the log. The majority of these are SIGENV, but the causes vary and there is no distinct explanation. Upon closer inspection of the records, it appears that there is a problem with the InputDispatcher:
Channel ‘9fa7335 my.company.com.android.debug/my.company.com.ui.login.LoginActivity(server)’ in InputDispatcher Channel has sustained irreparable harm and must be discarded!
Examining SO for this message, it appears to be associated with threading issues when manipulating non-“activity” activities.
Unfortunately, I am unable to provide reproducible code. Nonetheless, I utilize MockK in the MVP architecture as follows:
Check when you need to ensure that a method is being used.
Espresso View assertions are also included in these tests to validate the displayed UI.
Please provide all pertinent details regarding your configuration. This is crucial if the issue cannot be reproduced under specific conditions.