Kea2-python 0.0.1b1__tar.gz → 0.0.1b2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of Kea2-python might be problematic. Click here for more details.

Files changed (39) hide show
  1. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/Kea2_python.egg-info/PKG-INFO +26 -36
  2. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/Kea2_python.egg-info/SOURCES.txt +0 -1
  3. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/PKG-INFO +26 -36
  4. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/README.md +25 -35
  5. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/adbUtils.py +29 -1
  6. kea2_python-0.0.1b2/kea2/assets/monkeyq.jar +0 -0
  7. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/cli.py +1 -0
  8. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/keaUtils.py +38 -9
  9. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/kea_launcher.py +15 -4
  10. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/u2Driver.py +1 -1
  11. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/pyproject.toml +2 -2
  12. kea2_python-0.0.1b1/kea2/assets/fastbot_configs/ADBKeyBoard.apk +0 -0
  13. kea2_python-0.0.1b1/kea2/assets/monkeyq.jar +0 -0
  14. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/Kea2_python.egg-info/dependency_links.txt +0 -0
  15. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/Kea2_python.egg-info/entry_points.txt +0 -0
  16. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/Kea2_python.egg-info/requires.txt +0 -0
  17. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/Kea2_python.egg-info/top_level.txt +0 -0
  18. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/LICENSE +0 -0
  19. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/__init__.py +0 -0
  20. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/absDriver.py +0 -0
  21. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot-thirdpart.jar +0 -0
  22. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/abl.strings +0 -0
  23. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/awl.strings +0 -0
  24. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/max.config +0 -0
  25. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/max.fuzzing.strings +0 -0
  26. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/max.schema.strings +0 -0
  27. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/max.strings +0 -0
  28. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/max.tree.pruning +0 -0
  29. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_configs/widget.block.py +0 -0
  30. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_libs/arm64-v8a/libfastbot_native.so +0 -0
  31. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_libs/armeabi-v7a/libfastbot_native.so +0 -0
  32. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_libs/x86/libfastbot_native.so +0 -0
  33. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/fastbot_libs/x86_64/libfastbot_native.so +0 -0
  34. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/framework.jar +0 -0
  35. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/quicktest.py +0 -0
  36. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/assets/u2.jar +0 -0
  37. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/logWatcher.py +0 -0
  38. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/kea2/utils.py +0 -0
  39. {kea2_python-0.0.1b1 → kea2_python-0.0.1b2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 0.0.1b1
3
+ Version: 0.0.1b2
4
4
  Summary: A python library for supporting and customizing automated UI testing for mobile apps
5
5
  Author-email: Xixian Liang <xixian@stu.ecnu.edu.cn>
6
6
  Requires-Python: >=3.8
@@ -61,13 +61,14 @@ In the future, Kea2 will be extended to support
61
61
  Running requirements/environment:
62
62
  - support Windows, MacOS and Linux
63
63
  - python 3.8+
64
+ - Android 4.4+
64
65
  - Android SDK installed
65
66
  - **VPN closed** (Features 2 and 3 required)
66
67
 
67
68
 
68
69
  Install Kea2 by `pip`:
69
70
  ```bash
70
- python3 -m pip install Kea2-python
71
+ python3 -m pip install kea2-python
71
72
  ```
72
73
 
73
74
  Find Kea2's additional options by running
@@ -304,31 +305,6 @@ class MyFirstTest(unittest.TestCase):
304
305
 
305
306
  You can read [Kea - Write your fisrt property](https://kea-docs.readthedocs.io/en/latest/part-keaUserManuel/first_property.html) for more details.
306
307
 
307
- ### Notes
308
- Currently, in `@precondition` decorator and `widgets.block.py`. We only support basic selector (No parent-child relationship) in uiautomator2. The Script body in the function fully support uiautomator2.
309
-
310
- | | **Support** | **Not support** |
311
- | -- | -- | -- |
312
- | **Selctor** | `d(text="1").exist` | `d(text="1").child(text="2").exist` |
313
-
314
- If you need to specify `parent-child` relation ship in `@precondition`, specify it in xpath.
315
-
316
- for example:
317
-
318
- ```python
319
- # Do not use:
320
- # @precondition(lambda self:
321
- # self.d(className="android.widget.ListView").child(text="Bluetooth")
322
- # ):
323
- # ...
324
-
325
- # Use
326
- @precondition(lambda self:
327
- self.d.xpath('//android.widget.ListView/*[@text="Bluetooth"]')
328
- ):
329
- ...
330
- ```
331
-
332
308
 
333
309
  ## Launching Kea2
334
310
 
@@ -353,16 +329,17 @@ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --runn
353
329
  kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
354
330
  ```
355
331
 
356
- | arg | meaning |
357
- | --- | --- |
358
- | -s | The serial of your device, which can be found by `adb devices` |
359
- | -p | The tested app's package name (e.g., com.example.app) |
360
- | -o | The ouput directory for logs and results |
361
- | --agent | {native, u2}. By default, `u2` is used and supports all the three important features of Kea2. If you hope to run the orignal Fastbot, please use `native`.|
362
- | --running-minutes | The time (m) to run Kea2 |
363
- | --max-step | The maxium number of monkey events to send (only available in `--agent u2`) |
364
- | --throttle | The delay time (ms) between two monkey events |
332
+ | arg | meaning | default |
333
+ | --- | --- | --- |
334
+ | -s | The serial of your device, which can be found by `adb devices` | |
335
+ | -p | *The tested app's package name (e.g., com.example.app) |
336
+ | -o | The ouput directory for logs and results | `output` |
337
+ | --agent | {native, u2}. By default, `u2` is used and supports all the three important features of Kea2. If you hope to run the orignal Fastbot, please use `native`.| `u2` |
338
+ | --running-minutes | The time (m) to run Kea2 | `10` |
339
+ | --max-step | The maxium number of monkey events to send (only available in `--agent u2`) | `inf` |
340
+ | --throttle | The delay time (ms) between two monkey events | `200` |
365
341
  | --driver-name | The name of driver used in the script. If `--driver-name d` is specified, you should use `d` to interact with a device, e..g, `self.d(..).click()`. |
342
+ | --log-stamp | the stamp for log file and result file, default: current time stamp | |
366
343
  | unittest | Specify to load which scripts. This sub-command `unittest` is fully compatible with unittest. See `python3 -m unittest -h` for more options of unittest. This option is only available in `--agent u2`.
367
344
 
368
345
 
@@ -425,6 +402,8 @@ running_mins: int = 10
425
402
  throttle: int = 200
426
403
  # the output_dir for saving logs and results
427
404
  output_dir: str = "output"
405
+ # the stamp for log file and result file, default: current time stamp
406
+ log_stamp: str = None
428
407
  ```
429
408
 
430
409
  ## Examining the running statistics of scripts .
@@ -469,6 +448,17 @@ Kea2 has been actively developed and maintained by the people in [ecnusse](https
469
448
  - [uiautomator2](https://github.com/openatx/uiautomator2)
470
449
  - [hypothesis](https://github.com/HypothesisWorks/hypothesis)
471
450
 
451
+ ### Relevant papers of Kea2
452
+
453
+ > General and Practical Property-based Testing for Android Apps. ASE 2024. [pdf](https://dl.acm.org/doi/10.1145/3691620.3694986)
454
+
455
+ > An Empirical Study of Functional Bugs in Android Apps. ISSTA 2023. [pdf](https://dl.acm.org/doi/10.1145/3597926.3598138)
456
+
457
+ > Fastbot2: Reusable Automated Model-based GUI Testing for Android Enhanced by Reinforcement Learning. ASE 2022. [pdf](https://dl.acm.org/doi/10.1145/3551349.3559505)
458
+
459
+ > Guided, Stochastic Model-Based GUI Testing of Android Apps. ESEC/FSE 2017. [pdf](https://dl.acm.org/doi/10.1145/3106237.3106298)
460
+
461
+
472
462
  [^1]: 不少UI自动化测试工具提供了“自定义事件序列”能力(如[Fastbot](https://github.com/bytedance/Fastbot_Android/blob/main/handbook-cn.md#%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BA%8B%E4%BB%B6%E5%BA%8F%E5%88%97) 和[AppCrawler](https://github.com/seveniruby/AppCrawler)),但在实际使用中存在不少问题,如自定义能力有限、使用不灵活等。此前不少Fastbot用户抱怨过其“自定义事件序列”在使用中的问题,如[#209](https://github.com/bytedance/Fastbot_Android/issues/209), [#225](https://github.com/bytedance/Fastbot_Android/issues/225), [#286](https://github.com/bytedance/Fastbot_Android/issues/286)等。
473
463
 
474
464
  [^2]: 在UI自动化测试过程中支持自动断言是一个很重要的能力,但几乎没有测试工具提供这样的能力。我们注意到[AppCrawler](https://ceshiren.com/t/topic/15801/5)的开发者曾经希望提供一种断言机制,得到了用户的热切响应,不少用户从21年就开始催更,但始终未能实现。
@@ -21,7 +21,6 @@ kea2/assets/framework.jar
21
21
  kea2/assets/monkeyq.jar
22
22
  kea2/assets/quicktest.py
23
23
  kea2/assets/u2.jar
24
- kea2/assets/fastbot_configs/ADBKeyBoard.apk
25
24
  kea2/assets/fastbot_configs/abl.strings
26
25
  kea2/assets/fastbot_configs/awl.strings
27
26
  kea2/assets/fastbot_configs/max.config
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 0.0.1b1
3
+ Version: 0.0.1b2
4
4
  Summary: A python library for supporting and customizing automated UI testing for mobile apps
5
5
  Author-email: Xixian Liang <xixian@stu.ecnu.edu.cn>
6
6
  Requires-Python: >=3.8
@@ -61,13 +61,14 @@ In the future, Kea2 will be extended to support
61
61
  Running requirements/environment:
62
62
  - support Windows, MacOS and Linux
63
63
  - python 3.8+
64
+ - Android 4.4+
64
65
  - Android SDK installed
65
66
  - **VPN closed** (Features 2 and 3 required)
66
67
 
67
68
 
68
69
  Install Kea2 by `pip`:
69
70
  ```bash
70
- python3 -m pip install Kea2-python
71
+ python3 -m pip install kea2-python
71
72
  ```
72
73
 
73
74
  Find Kea2's additional options by running
@@ -304,31 +305,6 @@ class MyFirstTest(unittest.TestCase):
304
305
 
305
306
  You can read [Kea - Write your fisrt property](https://kea-docs.readthedocs.io/en/latest/part-keaUserManuel/first_property.html) for more details.
306
307
 
307
- ### Notes
308
- Currently, in `@precondition` decorator and `widgets.block.py`. We only support basic selector (No parent-child relationship) in uiautomator2. The Script body in the function fully support uiautomator2.
309
-
310
- | | **Support** | **Not support** |
311
- | -- | -- | -- |
312
- | **Selctor** | `d(text="1").exist` | `d(text="1").child(text="2").exist` |
313
-
314
- If you need to specify `parent-child` relation ship in `@precondition`, specify it in xpath.
315
-
316
- for example:
317
-
318
- ```python
319
- # Do not use:
320
- # @precondition(lambda self:
321
- # self.d(className="android.widget.ListView").child(text="Bluetooth")
322
- # ):
323
- # ...
324
-
325
- # Use
326
- @precondition(lambda self:
327
- self.d.xpath('//android.widget.ListView/*[@text="Bluetooth"]')
328
- ):
329
- ...
330
- ```
331
-
332
308
 
333
309
  ## Launching Kea2
334
310
 
@@ -353,16 +329,17 @@ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --runn
353
329
  kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
354
330
  ```
355
331
 
356
- | arg | meaning |
357
- | --- | --- |
358
- | -s | The serial of your device, which can be found by `adb devices` |
359
- | -p | The tested app's package name (e.g., com.example.app) |
360
- | -o | The ouput directory for logs and results |
361
- | --agent | {native, u2}. By default, `u2` is used and supports all the three important features of Kea2. If you hope to run the orignal Fastbot, please use `native`.|
362
- | --running-minutes | The time (m) to run Kea2 |
363
- | --max-step | The maxium number of monkey events to send (only available in `--agent u2`) |
364
- | --throttle | The delay time (ms) between two monkey events |
332
+ | arg | meaning | default |
333
+ | --- | --- | --- |
334
+ | -s | The serial of your device, which can be found by `adb devices` | |
335
+ | -p | *The tested app's package name (e.g., com.example.app) |
336
+ | -o | The ouput directory for logs and results | `output` |
337
+ | --agent | {native, u2}. By default, `u2` is used and supports all the three important features of Kea2. If you hope to run the orignal Fastbot, please use `native`.| `u2` |
338
+ | --running-minutes | The time (m) to run Kea2 | `10` |
339
+ | --max-step | The maxium number of monkey events to send (only available in `--agent u2`) | `inf` |
340
+ | --throttle | The delay time (ms) between two monkey events | `200` |
365
341
  | --driver-name | The name of driver used in the script. If `--driver-name d` is specified, you should use `d` to interact with a device, e..g, `self.d(..).click()`. |
342
+ | --log-stamp | the stamp for log file and result file, default: current time stamp | |
366
343
  | unittest | Specify to load which scripts. This sub-command `unittest` is fully compatible with unittest. See `python3 -m unittest -h` for more options of unittest. This option is only available in `--agent u2`.
367
344
 
368
345
 
@@ -425,6 +402,8 @@ running_mins: int = 10
425
402
  throttle: int = 200
426
403
  # the output_dir for saving logs and results
427
404
  output_dir: str = "output"
405
+ # the stamp for log file and result file, default: current time stamp
406
+ log_stamp: str = None
428
407
  ```
429
408
 
430
409
  ## Examining the running statistics of scripts .
@@ -469,6 +448,17 @@ Kea2 has been actively developed and maintained by the people in [ecnusse](https
469
448
  - [uiautomator2](https://github.com/openatx/uiautomator2)
470
449
  - [hypothesis](https://github.com/HypothesisWorks/hypothesis)
471
450
 
451
+ ### Relevant papers of Kea2
452
+
453
+ > General and Practical Property-based Testing for Android Apps. ASE 2024. [pdf](https://dl.acm.org/doi/10.1145/3691620.3694986)
454
+
455
+ > An Empirical Study of Functional Bugs in Android Apps. ISSTA 2023. [pdf](https://dl.acm.org/doi/10.1145/3597926.3598138)
456
+
457
+ > Fastbot2: Reusable Automated Model-based GUI Testing for Android Enhanced by Reinforcement Learning. ASE 2022. [pdf](https://dl.acm.org/doi/10.1145/3551349.3559505)
458
+
459
+ > Guided, Stochastic Model-Based GUI Testing of Android Apps. ESEC/FSE 2017. [pdf](https://dl.acm.org/doi/10.1145/3106237.3106298)
460
+
461
+
472
462
  [^1]: 不少UI自动化测试工具提供了“自定义事件序列”能力(如[Fastbot](https://github.com/bytedance/Fastbot_Android/blob/main/handbook-cn.md#%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BA%8B%E4%BB%B6%E5%BA%8F%E5%88%97) 和[AppCrawler](https://github.com/seveniruby/AppCrawler)),但在实际使用中存在不少问题,如自定义能力有限、使用不灵活等。此前不少Fastbot用户抱怨过其“自定义事件序列”在使用中的问题,如[#209](https://github.com/bytedance/Fastbot_Android/issues/209), [#225](https://github.com/bytedance/Fastbot_Android/issues/225), [#286](https://github.com/bytedance/Fastbot_Android/issues/286)等。
473
463
 
474
464
  [^2]: 在UI自动化测试过程中支持自动断言是一个很重要的能力,但几乎没有测试工具提供这样的能力。我们注意到[AppCrawler](https://ceshiren.com/t/topic/15801/5)的开发者曾经希望提供一种断言机制,得到了用户的热切响应,不少用户从21年就开始催更,但始终未能实现。
@@ -49,13 +49,14 @@ In the future, Kea2 will be extended to support
49
49
  Running requirements/environment:
50
50
  - support Windows, MacOS and Linux
51
51
  - python 3.8+
52
+ - Android 4.4+
52
53
  - Android SDK installed
53
54
  - **VPN closed** (Features 2 and 3 required)
54
55
 
55
56
 
56
57
  Install Kea2 by `pip`:
57
58
  ```bash
58
- python3 -m pip install Kea2-python
59
+ python3 -m pip install kea2-python
59
60
  ```
60
61
 
61
62
  Find Kea2's additional options by running
@@ -292,31 +293,6 @@ class MyFirstTest(unittest.TestCase):
292
293
 
293
294
  You can read [Kea - Write your fisrt property](https://kea-docs.readthedocs.io/en/latest/part-keaUserManuel/first_property.html) for more details.
294
295
 
295
- ### Notes
296
- Currently, in `@precondition` decorator and `widgets.block.py`. We only support basic selector (No parent-child relationship) in uiautomator2. The Script body in the function fully support uiautomator2.
297
-
298
- | | **Support** | **Not support** |
299
- | -- | -- | -- |
300
- | **Selctor** | `d(text="1").exist` | `d(text="1").child(text="2").exist` |
301
-
302
- If you need to specify `parent-child` relation ship in `@precondition`, specify it in xpath.
303
-
304
- for example:
305
-
306
- ```python
307
- # Do not use:
308
- # @precondition(lambda self:
309
- # self.d(className="android.widget.ListView").child(text="Bluetooth")
310
- # ):
311
- # ...
312
-
313
- # Use
314
- @precondition(lambda self:
315
- self.d.xpath('//android.widget.ListView/*[@text="Bluetooth"]')
316
- ):
317
- ...
318
- ```
319
-
320
296
 
321
297
  ## Launching Kea2
322
298
 
@@ -341,16 +317,17 @@ kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --runn
341
317
  kea2 run -s "emulator-5554" -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d unittest discover -s mytests/omni_notes
342
318
  ```
343
319
 
344
- | arg | meaning |
345
- | --- | --- |
346
- | -s | The serial of your device, which can be found by `adb devices` |
347
- | -p | The tested app's package name (e.g., com.example.app) |
348
- | -o | The ouput directory for logs and results |
349
- | --agent | {native, u2}. By default, `u2` is used and supports all the three important features of Kea2. If you hope to run the orignal Fastbot, please use `native`.|
350
- | --running-minutes | The time (m) to run Kea2 |
351
- | --max-step | The maxium number of monkey events to send (only available in `--agent u2`) |
352
- | --throttle | The delay time (ms) between two monkey events |
320
+ | arg | meaning | default |
321
+ | --- | --- | --- |
322
+ | -s | The serial of your device, which can be found by `adb devices` | |
323
+ | -p | *The tested app's package name (e.g., com.example.app) |
324
+ | -o | The ouput directory for logs and results | `output` |
325
+ | --agent | {native, u2}. By default, `u2` is used and supports all the three important features of Kea2. If you hope to run the orignal Fastbot, please use `native`.| `u2` |
326
+ | --running-minutes | The time (m) to run Kea2 | `10` |
327
+ | --max-step | The maxium number of monkey events to send (only available in `--agent u2`) | `inf` |
328
+ | --throttle | The delay time (ms) between two monkey events | `200` |
353
329
  | --driver-name | The name of driver used in the script. If `--driver-name d` is specified, you should use `d` to interact with a device, e..g, `self.d(..).click()`. |
330
+ | --log-stamp | the stamp for log file and result file, default: current time stamp | |
354
331
  | unittest | Specify to load which scripts. This sub-command `unittest` is fully compatible with unittest. See `python3 -m unittest -h` for more options of unittest. This option is only available in `--agent u2`.
355
332
 
356
333
 
@@ -413,6 +390,8 @@ running_mins: int = 10
413
390
  throttle: int = 200
414
391
  # the output_dir for saving logs and results
415
392
  output_dir: str = "output"
393
+ # the stamp for log file and result file, default: current time stamp
394
+ log_stamp: str = None
416
395
  ```
417
396
 
418
397
  ## Examining the running statistics of scripts .
@@ -457,6 +436,17 @@ Kea2 has been actively developed and maintained by the people in [ecnusse](https
457
436
  - [uiautomator2](https://github.com/openatx/uiautomator2)
458
437
  - [hypothesis](https://github.com/HypothesisWorks/hypothesis)
459
438
 
439
+ ### Relevant papers of Kea2
440
+
441
+ > General and Practical Property-based Testing for Android Apps. ASE 2024. [pdf](https://dl.acm.org/doi/10.1145/3691620.3694986)
442
+
443
+ > An Empirical Study of Functional Bugs in Android Apps. ISSTA 2023. [pdf](https://dl.acm.org/doi/10.1145/3597926.3598138)
444
+
445
+ > Fastbot2: Reusable Automated Model-based GUI Testing for Android Enhanced by Reinforcement Learning. ASE 2022. [pdf](https://dl.acm.org/doi/10.1145/3551349.3559505)
446
+
447
+ > Guided, Stochastic Model-Based GUI Testing of Android Apps. ESEC/FSE 2017. [pdf](https://dl.acm.org/doi/10.1145/3106237.3106298)
448
+
449
+
460
450
  [^1]: 不少UI自动化测试工具提供了“自定义事件序列”能力(如[Fastbot](https://github.com/bytedance/Fastbot_Android/blob/main/handbook-cn.md#%E8%87%AA%E5%AE%9A%E4%B9%89%E4%BA%8B%E4%BB%B6%E5%BA%8F%E5%88%97) 和[AppCrawler](https://github.com/seveniruby/AppCrawler)),但在实际使用中存在不少问题,如自定义能力有限、使用不灵活等。此前不少Fastbot用户抱怨过其“自定义事件序列”在使用中的问题,如[#209](https://github.com/bytedance/Fastbot_Android/issues/209), [#225](https://github.com/bytedance/Fastbot_Android/issues/225), [#286](https://github.com/bytedance/Fastbot_Android/issues/286)等。
461
451
 
462
452
  [^2]: 在UI自动化测试过程中支持自动断言是一个很重要的能力,但几乎没有测试工具提供这样的能力。我们注意到[AppCrawler](https://ceshiren.com/t/topic/15801/5)的开发者曾经希望提供一种断言机制,得到了用户的热切响应,不少用户从21年就开始催更,但始终未能实现。
@@ -1,5 +1,5 @@
1
1
  import subprocess
2
- from typing import List, Optional
2
+ from typing import List, Optional, Set
3
3
  from .utils import getLogger
4
4
 
5
5
  logger = getLogger(__name__)
@@ -223,6 +223,34 @@ def remove_all_forwards(device: Optional[str] = None):
223
223
  return run_adb_command(["-s", device, "forward", "--remove-all"])
224
224
 
225
225
 
226
+ @ensure_device
227
+ def get_packages(device: Optional[str] = None) -> Set[str]:
228
+ """
229
+ Retrieves packages that match the specified regular expression pattern.
230
+
231
+ Parameters:
232
+ pattern (str): Regular expression pattern to match package names.
233
+ device (str, optional): The device serial number. If None, it is resolved automatically.
234
+
235
+ Returns:
236
+ set: A set of package names that match the pattern.
237
+ """
238
+ import re
239
+
240
+ cmd = ["-s", device, "shell", "pm", "list", "packages"]
241
+ output = run_adb_command(cmd)
242
+
243
+ packages = set()
244
+ if output:
245
+ compiled_pattern = re.compile(r"package:(.+)\n")
246
+ matches = compiled_pattern.findall(output)
247
+ for match in matches:
248
+ if match:
249
+ packages.add(match)
250
+
251
+ return packages
252
+
253
+
226
254
  if __name__ == '__main__':
227
255
  # For testing: print the list of currently connected devices.
228
256
  devices = get_devices()
@@ -99,6 +99,7 @@ def main():
99
99
  args = parser.parse_args()
100
100
 
101
101
  import logging
102
+ logging.basicConfig(level=logging.INFO)
102
103
  if args.debug:
103
104
  logging.basicConfig(level=logging.DEBUG)
104
105
  logger.debug("args: %s", args)
@@ -119,6 +119,13 @@ class Options:
119
119
  output_dir: str = "output"
120
120
  # the stamp for log file and result file, default: current time stamp
121
121
  log_stamp: str = None
122
+ # the profiling period to get the coverage result.
123
+ profile_period: int = None
124
+
125
+ def __setattr__(self, name, value):
126
+ if value is None:
127
+ return
128
+ super().__setattr__(name, value)
122
129
 
123
130
  def __post_init__(self):
124
131
  if self.serial and self.Driver:
@@ -127,6 +134,17 @@ class Options:
127
134
  global LOGFILE, RESFILE
128
135
  LOGFILE = f"fastbot_{self.log_stamp}.log"
129
136
  RESFILE = f"result_{self.log_stamp}.json"
137
+ _check_package_installation(self.serial, self.packageNames)
138
+
139
+
140
+ def _check_package_installation(serial, packageNames):
141
+ from .adbUtils import get_packages
142
+ installed_packages = get_packages(device=serial)
143
+
144
+ for package in packageNames:
145
+ if package not in installed_packages:
146
+ logger.error(f"package {package} not installed. Abort.")
147
+ raise ValueError("package not installed")
130
148
 
131
149
 
132
150
  @dataclass
@@ -257,7 +275,7 @@ def startFastbotService(options: Options) -> threading.Thread:
257
275
  "reuseq",
258
276
  "--running-minutes", f"{options.running_mins}",
259
277
  "--throttle", f"{options.throttle}",
260
- "--bugreport", "--output-directory", "/sdcard/fastbot_report"
278
+ "--bugreport", "--output-directory", "/sdcard/fastbot_report",
261
279
  "-v", "-v", "-v"
262
280
  ]
263
281
 
@@ -354,18 +372,20 @@ class KeaTestRunner(TextTestRunner):
354
372
  check_alive(port=self.scriptDriver.lport)
355
373
 
356
374
  end_by_remote = False
357
- step = 0
358
- while step < self.options.maxStep:
375
+ self.stepsCount = 0
376
+ while self.stepsCount < self.options.maxStep:
359
377
 
360
- step += 1
378
+ self.stepsCount += 1
361
379
  print("[INFO] Sending monkeyEvent {}".format(
362
- f"({step} / {self.options.maxStep})" if self.options.maxStep != float("inf")
363
- else f"({step})"
380
+ f"({self.stepsCount} / {self.options.maxStep})" if self.options.maxStep != float("inf")
381
+ else f"({self.stepsCount})"
364
382
  )
365
383
  , flush=True)
366
384
 
367
385
  try:
368
- propsSatisfiedPrecond = self.getValidProperties(result)
386
+ xml_raw = self.stepMonkey()
387
+ stat = self._getStat()
388
+ propsSatisfiedPrecond = self.getValidProperties(xml_raw, result)
369
389
  except requests.ConnectionError:
370
390
  print(
371
391
  "[INFO] Exploration times up (--running-minutes)."
@@ -462,6 +482,7 @@ class KeaTestRunner(TextTestRunner):
462
482
  r = requests.post(
463
483
  url=URL,
464
484
  json={
485
+ "steps_count": self.stepsCount,
465
486
  "block_widgets": block_widgets
466
487
  }
467
488
  )
@@ -481,9 +502,8 @@ class KeaTestRunner(TextTestRunner):
481
502
  res = r.content.decode(encoding="utf-8")
482
503
  print(f"[Server INFO] {res}", flush=True)
483
504
 
484
- def getValidProperties(self, result: JsonResult) -> PropertyStore:
505
+ def getValidProperties(self, xml_raw: str, result: JsonResult) -> PropertyStore:
485
506
 
486
- xml_raw = self.stepMonkey()
487
507
  staticCheckerDriver = self.options.Driver.getStaticChecker(hierarchy=xml_raw)
488
508
 
489
509
  validProps: PropertyStore = dict()
@@ -513,6 +533,15 @@ class KeaTestRunner(TextTestRunner):
513
533
  validProps[propName] = test
514
534
  return validProps
515
535
 
536
+ def _getStat(self):
537
+ # profile when reaching the profile period
538
+ if (self.options.profile_period and
539
+ self.stepsCount % self.options.profile_period == 0
540
+ ):
541
+ URL = f"http://localhost:{self.scriptDriver.lport}/getStat"
542
+ r = requests.get(URL)
543
+ res = json.loads(r.content)
544
+
516
545
  def collectAllProperties(self, test: TestSuite):
517
546
  """collect all the properties to prepare for PBT
518
547
  """
@@ -83,6 +83,14 @@ def _set_runner_parser(subparsers: "argparse._SubParsersAction[argparse.Argument
83
83
  required=False,
84
84
  help="the stamp for log file and result file, default: current time stamp",
85
85
  )
86
+
87
+ parser.add_argument(
88
+ "--profile-period",
89
+ dest="profile_period",
90
+ type=int,
91
+ required=False,
92
+ help="Steps to profile the testing statistics.",
93
+ )
86
94
 
87
95
  parser.add_argument(
88
96
  "extra",
@@ -120,6 +128,7 @@ def parse_args(argv: List):
120
128
  args = parser.parse_args(argv)
121
129
  return args
122
130
 
131
+
123
132
  def _sanitize_args(args):
124
133
  if args.agent == "u2" and not args.driver_name:
125
134
  if args.extra == []:
@@ -127,6 +136,7 @@ def _sanitize_args(args):
127
136
  else:
128
137
  raise ValueError("--driver-name should be specified when customizing script in --agent u2")
129
138
 
139
+
130
140
  def run(args=None):
131
141
  if args is None:
132
142
  args = parse_args(sys.argv[1:])
@@ -144,10 +154,11 @@ def run(args=None):
144
154
  Driver=U2Driver,
145
155
  packageNames=args.package_names,
146
156
  serial=args.serial,
147
- running_mins=args.running_minutes if args.running_minutes else 10,
148
- maxStep=args.max_step if args.max_step else 500,
149
- throttle=args.throttle_ms if args.throttle_ms else 200,
150
- log_stamp=args.log_stamp
157
+ running_mins=args.running_minutes,
158
+ maxStep=args.max_step,
159
+ throttle=args.throttle_ms,
160
+ log_stamp=args.log_stamp,
161
+ profile_period=args.profile_period,
151
162
  )
152
163
 
153
164
  KeaTestRunner.setOptions(options)
@@ -235,7 +235,7 @@ class U2StaticDevice(u2.Device):
235
235
 
236
236
  def __getattr__(self, attr):
237
237
  """Proxy other methods to script_driver"""
238
- # logger.debug(f"{attr} not exists in static checker, proxy to script_driver.")
238
+ logger.debug(f"{attr} not exists in static checker, proxy to script_driver.")
239
239
  return getattr(self._script_driver, attr)
240
240
 
241
241
  class _XPathEntry(u2.xpath.XPathEntry):
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Kea2-python"
3
- version = "0.0.1b1"
3
+ version = "0.0.1b2"
4
4
  description = "A python library for supporting and customizing automated UI testing for mobile apps"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.8"
@@ -19,4 +19,4 @@ kea2 = "kea2.cli:main"
19
19
  include = ["kea2"]
20
20
 
21
21
  [tool.setuptools.package-data]
22
- kea2 = ["assets/**/*"]
22
+ kea2 = ["assets/**/*"]
Binary file
File without changes
File without changes