Answer: yes, you can run an automation test using Espresso without the application source code.
Espresso is based on the platform of Android tools, which means that the automation test is built into one apk test. This apk test is different from a regular apk application:
The AndroidManifest.xml registered equipment that will be registered in the Android system after installing the apk test
The apk test must be signed using the same signature with the apk application in order to run the automation test
Apk testing is performed in the same process as apk application
Above are only requirements for any tool-based platform. Thus, there is no source code dependency.
But why do we find that most Espresso tutorials mix with source code? Because it will simplify the test:
You can easily manage the life cycle of an activity using the ActivityTestRule class.
You can easily test the classes defined by the application.
You can check the widgets of the user interface using the widget id
On the contrary, you need to write a lot of reflection code to get the classes you need if you do not compile the source code. For instance:
You should use Class.forName to load login activity and run it
You must use Java reflection to test specific classes.
You need to use literal information to search for a user interface widget because you do not have an identifier for the user interface widget
I think this is due to the aforementioned shortcomings, which makes Google prefer to create the Espresso test along with the source code.
To summarize, itβs fine to run the Espresso automation test without the application source code, but itβs a lot harder to make the error codes ugly.
You can reference the sample AndroidTestWithoutSource project.
source share