Some thoughts about End to End test on Weex Android. I spent some time this week coding for Android End to End test using the test framework Android itself provided. After all, any fancy test frameworks for Android is an encapsulation of Android Test framework. Here is what I got:
If you run a test case without Android Emulator, all the Android API in a test case is actually mock APIs by a test framework, not provided by Android system, which means the behavior of mocks and Android system itself is different in some aspect. In the situation of Weex, I am stocked by loading and running shared library running on Android in test framework (Robolectric). It is very unlikely that we could load and run all of the 8 shared libraries built for Mobile x86 platform in Weex originally on Linux x86 platform when running test case, especially some of them dynamically links to shared libraries in Android system itself. If we are running test case with Android Emulator on Travis CI, we can get everything we get want by expanding a test framework called espresso[1]. The only problem here is Android emulator on Travis CI is really slow due to nested-virtualization problems of Travis-CI [2]. As this is caused by the KVM virtualization technology, I don’t think we can get over the emulator performance problem in a easy way. [1] https://developer.android.com/training/testing/espresso <https://developer.android.com/training/testing/espresso> [2] https://travis-ci.community/t/add-kvm-support/1406/10 <https://travis-ci.community/t/add-kvm-support/1406/10> > 在 2019年8月12日,11:08,王仁敏 <[email protected]> 写道: > > I have recently designed a test framework with York, and we want to add > some end-to-end test cases to improve the stability and robustness of Weex. > > > Our expected testing framework want to verify basic properties of the View, > instead of plain text(Because plain text verification has too many > limitations) > > > > For all test cases, the following three processes are required: > > 1. Create UIViewController/Activity > > 2. Simulate user input > > 3. Check if the result is right > > > We thought of several possible solutions: > > > ## 1. Based on the pure Native testing framework. > > Weex provides the ability to load pages from a URL file. If you don't rely > on the emulator, you need call some interface to convert the URL to a page > (York said this process can't build success) > > > ## 2. Based on the Detox(end-to-end framework) and simulator. > > - Create page: build the page based on the URL (the entire Android > project is already running, so we can call the interface) > - Simulate user input: (1) simulate user input via JS (2) simulate user > click event using native code > - Test result: on the Native Side, compare View's properties with the > expected. If it is consistent, notify the JS the test case is succeeded, > otherwise, notify the JS the test case is failed. > > But Android emulator has many limitations. According to our survey, the > Travis CI Android emulator is slower, and the X86 emulator Google has not > been updated for three years, and the ARM emulator is subject to the Travis > CI architecture. > > > @Jan, I learn about you have done some works about > Cordova-testing-framework recently. How do you solve this problem? > > > I will be very appreciated if anyone can help me, thanks very much! > > > Best wished. > > Renmin
