Kea2-python 1.0.3__tar.gz → 1.0.4__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.
Files changed (59) hide show
  1. {kea2_python-1.0.3 → kea2_python-1.0.4}/Kea2_python.egg-info/PKG-INFO +51 -17
  2. {kea2_python-1.0.3 → kea2_python-1.0.4}/Kea2_python.egg-info/SOURCES.txt +3 -1
  3. {kea2_python-1.0.3 → kea2_python-1.0.4}/PKG-INFO +51 -17
  4. {kea2_python-1.0.3 → kea2_python-1.0.4}/README.md +50 -16
  5. kea2_python-1.0.4/kea2/__init__.py +3 -0
  6. kea2_python-1.0.4/kea2/assets/fastbot_libs/arm64-v8a/libfastbot_native.so +0 -0
  7. kea2_python-1.0.4/kea2/assets/fastbot_libs/armeabi-v7a/libfastbot_native.so +0 -0
  8. kea2_python-1.0.4/kea2/assets/fastbot_libs/x86/libfastbot_native.so +0 -0
  9. kea2_python-1.0.4/kea2/assets/fastbot_libs/x86_64/libfastbot_native.so +0 -0
  10. kea2_python-1.0.4/kea2/assets/monkeyq.jar +0 -0
  11. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/cli.py +6 -7
  12. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/fastbotManager.py +53 -51
  13. kea2_python-1.0.4/kea2/kea2_api.py +166 -0
  14. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/keaUtils.py +34 -19
  15. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/report/report_merger.py +91 -6
  16. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/u2Driver.py +78 -67
  17. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/utils.py +29 -1
  18. {kea2_python-1.0.3 → kea2_python-1.0.4}/pyproject.toml +1 -1
  19. kea2_python-1.0.4/tests/test_xpath.py +36 -0
  20. kea2_python-1.0.3/kea2/__init__.py +0 -1
  21. kea2_python-1.0.3/kea2/assets/fastbot_libs/arm64-v8a/libfastbot_native.so +0 -0
  22. kea2_python-1.0.3/kea2/assets/fastbot_libs/armeabi-v7a/libfastbot_native.so +0 -0
  23. kea2_python-1.0.3/kea2/assets/fastbot_libs/x86/libfastbot_native.so +0 -0
  24. kea2_python-1.0.3/kea2/assets/fastbot_libs/x86_64/libfastbot_native.so +0 -0
  25. kea2_python-1.0.3/kea2/assets/monkeyq.jar +0 -0
  26. {kea2_python-1.0.3 → kea2_python-1.0.4}/Kea2_python.egg-info/dependency_links.txt +0 -0
  27. {kea2_python-1.0.3 → kea2_python-1.0.4}/Kea2_python.egg-info/entry_points.txt +0 -0
  28. {kea2_python-1.0.3 → kea2_python-1.0.4}/Kea2_python.egg-info/requires.txt +0 -0
  29. {kea2_python-1.0.3 → kea2_python-1.0.4}/Kea2_python.egg-info/top_level.txt +0 -0
  30. {kea2_python-1.0.3 → kea2_python-1.0.4}/LICENSE +0 -0
  31. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/absDriver.py +0 -0
  32. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/adbUtils.py +0 -0
  33. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/config_version.json +0 -0
  34. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot-thirdpart.jar +0 -0
  35. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/abl.strings +0 -0
  36. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/awl.strings +0 -0
  37. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/max.config +0 -0
  38. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/max.fuzzing.strings +0 -0
  39. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/max.schema.strings +0 -0
  40. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/max.strings +0 -0
  41. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/max.tree.pruning +0 -0
  42. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/teardown.py +0 -0
  43. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/fastbot_configs/widget.block.py +0 -0
  44. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/framework.jar +0 -0
  45. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/kea2-thirdpart.jar +0 -0
  46. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/assets/quicktest.py +0 -0
  47. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/kea_launcher.py +0 -0
  48. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/logWatcher.py +0 -0
  49. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/mixin.py +0 -0
  50. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/report/__init__.py +0 -0
  51. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/report/bug_report_generator.py +0 -0
  52. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/report/mixin.py +0 -0
  53. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/report/templates/bug_report_template.html +0 -0
  54. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/report/templates/merged_bug_report_template.html +0 -0
  55. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/report/utils.py +0 -0
  56. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/resultSyncer.py +0 -0
  57. {kea2_python-1.0.3 → kea2_python-1.0.4}/kea2/version_manager.py +0 -0
  58. {kea2_python-1.0.3 → kea2_python-1.0.4}/setup.cfg +0 -0
  59. {kea2_python-1.0.3 → kea2_python-1.0.4}/tests/test_u2Selector.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 1.0.3
3
+ Version: 1.0.4
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
@@ -26,8 +26,11 @@ Dynamic: license-file
26
26
 
27
27
  Please contact Xixian Liang at [xixian@stu.ecnu.edu.cn](xixian@stu.ecnu.edu.cn) with your Wechat ID / QR code to be invited to the WeChat discussion group. Of course, we are also ready on GitHub to answer your questions/feedback.
28
28
 
29
- ### Github repo link
30
- [https://github.com/ecnusse/Kea2](https://github.com/ecnusse/Kea2)
29
+ #### Github repo [https://github.com/ecnusse/Kea2](https://github.com/ecnusse/Kea2)
30
+ #### Gitee mirror [https://gitee.com/XixianLiang/Kea2](https://gitee.com/XixianLiang/Kea2)
31
+
32
+
33
+
31
34
 
32
35
  ### [点击此处:查看中文文档](README_cn.md)
33
36
 
@@ -208,7 +211,7 @@ You can find the full example in script `quicktest.py`, and run this script with
208
211
 
209
212
  ```bash
210
213
  # Launch Kea2 and load one single script quicktest.py.
211
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d propertytest discover -p quicktest.py
214
+ kea2 run -p it.feio.android.omninotes.alpha --running-minutes 10 --throttle 200 --driver-name d propertytest discover -p quicktest.py
212
215
  ```
213
216
 
214
217
  ## Feature 3(运行增强版Fastbot:加入自动断言)
@@ -243,7 +246,8 @@ For the preceding always-holding property, we can write the following script to
243
246
  )
244
247
  def test_input_box(self):
245
248
 
246
- # genenerate a random non-empty string (this is also property-based testing by feeding random text inputs!)
249
+ # genenerate a random non-empty string (this is also property-based testing
250
+ # by feeding random text inputs!)
247
251
  from hypothesis.strategies import text, ascii_letters
248
252
  random_str = text(alphabet=ascii_letters).example()
249
253
 
@@ -261,9 +265,7 @@ For the preceding always-holding property, we can write the following script to
261
265
 
262
266
  You can run this example by using the similar command line in Feature 2.
263
267
 
264
- ## Feature 4 (Experimental feature, 实验中,脚本与遍历的混合测试)
265
-
266
- > This feature is still under development. We are looking forward to your feedback! Contact us if you're interested in this feature.
268
+ ## Feature 4(兼容已有脚本:通过前置脚本步骤到达特定层次)
267
269
 
268
270
  Kea2 supports reusing existing Ui test Scripts. We are inspired by the idea that: *The existing Ui test scripts usually cover important app functionalities and can reach deep app states. Thus, they can be used as good "guiding scripts" to drive Fastbot to explore important and deep app states.*
269
271
 
@@ -271,22 +273,54 @@ For example, you may already have some existing Ui test scripts "login and add a
271
273
 
272
274
  ### Example
273
275
 
274
- See [guide_scripts.py](guide_scripts.py) for a full example.
276
+ Here are four example scripts in hybridetest_examples, each corresponding to different forms of user scripts, showing you how to launch kea2 in the existing code.
275
277
 
276
- By the decorator `@interruptable`, you can mark the testcase as "interruptable" so that Kea2 can recognize this script and launch fuzzing test after it returns.
278
+ Specifically:
277
279
 
278
- Since the state of app is probably unpredicted after fuzzing tests, Kea2 provides a `common_teardown` function to clean up the environment between previous script and next script. The function can be manually specified in `configs/teardown.py`.
280
+ * [u2_unittest_example.py](hybridtest_examples\u2_unittest_example.py) is a u2 script organized with unittest.
281
+ * [u2_pytest_example.py](hybridtest_examples\u2_pytest_example.py) is a u2 script organized with pytest.
282
+ * [appium_unittest_example.py](hybridtest_examples\appium_unittest_example.py) is an appium script organized with unittest.
283
+ * [appium_pytest_example.py](hybridtest_examples\appium_pytest_example.py) is an appium script organized with pytest.
279
284
 
280
- You can find the full example in `guide_scripts.py`, `property_omninotes.py` and `configs/teardown.py` . You can run one of the following commands:
285
+ Some notes:
281
286
 
282
- ```bash
283
- # Guide with guide_scripts.py and launch fuzzing test after every script.
284
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 500 --max-step 15 --driver-name d unittest discover -p guide_scripts.py
287
+ 1. You can control whether to execute the kea2-related code you have written by modifying the condition of 'if'. This allows you to easily enable or disable kea2 operations in the same script. Here we use environment variable as an example.
288
+ 2. Since kea2 is driven by u2, if an appium-written script wants to launch kea2, it is necessary to first close the appium session. Remember to configure the parameter `"noReset": True` in `desired_caps` to avoid resetting the application when closing the session.
289
+ 3. You need to insert the following code template into your existing test cases: Here, you can add your own hook logic in the commented sections, including starting or stopping the appium session, cleaning up instances, etc. This depends on how you want to design the setup and teardown. Apart from that, you only need to configure the `option` parameter and `configs_path` parameter(where your directory `configs` located, btw, `configs`'s location dependon where you executed `kea2 init`), then pass it to the `run_kea2_testing` function.
290
+
291
+ ```python
292
+ from kea2 import Kea2Tester, Options, U2Driver
285
293
 
286
- # Guide with guide_scripts.py and launch fuzzing test after every script(check properties during fuzzing).
287
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 500 --max-step 15 --driver-name d unittest discover -p guide_scripts.py propertytest discover -p quickstart2.py
294
+ if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
295
+ '''
296
+ Note: The if condition here can be modified as needed according to the actual
297
+ situation of the project, the form of environment variables is just an example.
298
+ '''
299
+
300
+ # close your driver session etc. here
301
+ # ...
302
+
303
+ tester = Kea2Tester()
304
+ result = self.tester.run_kea2_testing(
305
+ Options(
306
+ driverName="d",
307
+ packageNames=[PACKAGE_NAME],
308
+ propertytest_args=["discover", "-p", "Omninotes_Sample.py"],
309
+ serial=DEVICE_SERIAL,
310
+ running_mins=2,
311
+ maxStep=20
312
+ ),
313
+ configs_path = None # Default, if your configs folder is located in the root directory, miss this.
314
+ )
315
+
316
+ # restart your driver session or clean instance here
317
+ # ...
318
+
319
+ return # this make your following steps of this testcase not work
288
320
  ```
289
321
 
322
+
323
+
290
324
  ## Test Reports(测试报告)
291
325
 
292
326
  Kea2 automatically generates a HTML test report after each testing session. You can find the report in `output/` under your working directory.
@@ -12,6 +12,7 @@ kea2/absDriver.py
12
12
  kea2/adbUtils.py
13
13
  kea2/cli.py
14
14
  kea2/fastbotManager.py
15
+ kea2/kea2_api.py
15
16
  kea2/keaUtils.py
16
17
  kea2/kea_launcher.py
17
18
  kea2/logWatcher.py
@@ -46,4 +47,5 @@ kea2/report/report_merger.py
46
47
  kea2/report/utils.py
47
48
  kea2/report/templates/bug_report_template.html
48
49
  kea2/report/templates/merged_bug_report_template.html
49
- tests/test_u2Selector.py
50
+ tests/test_u2Selector.py
51
+ tests/test_xpath.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Kea2-python
3
- Version: 1.0.3
3
+ Version: 1.0.4
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
@@ -26,8 +26,11 @@ Dynamic: license-file
26
26
 
27
27
  Please contact Xixian Liang at [xixian@stu.ecnu.edu.cn](xixian@stu.ecnu.edu.cn) with your Wechat ID / QR code to be invited to the WeChat discussion group. Of course, we are also ready on GitHub to answer your questions/feedback.
28
28
 
29
- ### Github repo link
30
- [https://github.com/ecnusse/Kea2](https://github.com/ecnusse/Kea2)
29
+ #### Github repo [https://github.com/ecnusse/Kea2](https://github.com/ecnusse/Kea2)
30
+ #### Gitee mirror [https://gitee.com/XixianLiang/Kea2](https://gitee.com/XixianLiang/Kea2)
31
+
32
+
33
+
31
34
 
32
35
  ### [点击此处:查看中文文档](README_cn.md)
33
36
 
@@ -208,7 +211,7 @@ You can find the full example in script `quicktest.py`, and run this script with
208
211
 
209
212
  ```bash
210
213
  # Launch Kea2 and load one single script quicktest.py.
211
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d propertytest discover -p quicktest.py
214
+ kea2 run -p it.feio.android.omninotes.alpha --running-minutes 10 --throttle 200 --driver-name d propertytest discover -p quicktest.py
212
215
  ```
213
216
 
214
217
  ## Feature 3(运行增强版Fastbot:加入自动断言)
@@ -243,7 +246,8 @@ For the preceding always-holding property, we can write the following script to
243
246
  )
244
247
  def test_input_box(self):
245
248
 
246
- # genenerate a random non-empty string (this is also property-based testing by feeding random text inputs!)
249
+ # genenerate a random non-empty string (this is also property-based testing
250
+ # by feeding random text inputs!)
247
251
  from hypothesis.strategies import text, ascii_letters
248
252
  random_str = text(alphabet=ascii_letters).example()
249
253
 
@@ -261,9 +265,7 @@ For the preceding always-holding property, we can write the following script to
261
265
 
262
266
  You can run this example by using the similar command line in Feature 2.
263
267
 
264
- ## Feature 4 (Experimental feature, 实验中,脚本与遍历的混合测试)
265
-
266
- > This feature is still under development. We are looking forward to your feedback! Contact us if you're interested in this feature.
268
+ ## Feature 4(兼容已有脚本:通过前置脚本步骤到达特定层次)
267
269
 
268
270
  Kea2 supports reusing existing Ui test Scripts. We are inspired by the idea that: *The existing Ui test scripts usually cover important app functionalities and can reach deep app states. Thus, they can be used as good "guiding scripts" to drive Fastbot to explore important and deep app states.*
269
271
 
@@ -271,22 +273,54 @@ For example, you may already have some existing Ui test scripts "login and add a
271
273
 
272
274
  ### Example
273
275
 
274
- See [guide_scripts.py](guide_scripts.py) for a full example.
276
+ Here are four example scripts in hybridetest_examples, each corresponding to different forms of user scripts, showing you how to launch kea2 in the existing code.
275
277
 
276
- By the decorator `@interruptable`, you can mark the testcase as "interruptable" so that Kea2 can recognize this script and launch fuzzing test after it returns.
278
+ Specifically:
277
279
 
278
- Since the state of app is probably unpredicted after fuzzing tests, Kea2 provides a `common_teardown` function to clean up the environment between previous script and next script. The function can be manually specified in `configs/teardown.py`.
280
+ * [u2_unittest_example.py](hybridtest_examples\u2_unittest_example.py) is a u2 script organized with unittest.
281
+ * [u2_pytest_example.py](hybridtest_examples\u2_pytest_example.py) is a u2 script organized with pytest.
282
+ * [appium_unittest_example.py](hybridtest_examples\appium_unittest_example.py) is an appium script organized with unittest.
283
+ * [appium_pytest_example.py](hybridtest_examples\appium_pytest_example.py) is an appium script organized with pytest.
279
284
 
280
- You can find the full example in `guide_scripts.py`, `property_omninotes.py` and `configs/teardown.py` . You can run one of the following commands:
285
+ Some notes:
281
286
 
282
- ```bash
283
- # Guide with guide_scripts.py and launch fuzzing test after every script.
284
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 500 --max-step 15 --driver-name d unittest discover -p guide_scripts.py
287
+ 1. You can control whether to execute the kea2-related code you have written by modifying the condition of 'if'. This allows you to easily enable or disable kea2 operations in the same script. Here we use environment variable as an example.
288
+ 2. Since kea2 is driven by u2, if an appium-written script wants to launch kea2, it is necessary to first close the appium session. Remember to configure the parameter `"noReset": True` in `desired_caps` to avoid resetting the application when closing the session.
289
+ 3. You need to insert the following code template into your existing test cases: Here, you can add your own hook logic in the commented sections, including starting or stopping the appium session, cleaning up instances, etc. This depends on how you want to design the setup and teardown. Apart from that, you only need to configure the `option` parameter and `configs_path` parameter(where your directory `configs` located, btw, `configs`'s location dependon where you executed `kea2 init`), then pass it to the `run_kea2_testing` function.
290
+
291
+ ```python
292
+ from kea2 import Kea2Tester, Options, U2Driver
285
293
 
286
- # Guide with guide_scripts.py and launch fuzzing test after every script(check properties during fuzzing).
287
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 500 --max-step 15 --driver-name d unittest discover -p guide_scripts.py propertytest discover -p quickstart2.py
294
+ if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
295
+ '''
296
+ Note: The if condition here can be modified as needed according to the actual
297
+ situation of the project, the form of environment variables is just an example.
298
+ '''
299
+
300
+ # close your driver session etc. here
301
+ # ...
302
+
303
+ tester = Kea2Tester()
304
+ result = self.tester.run_kea2_testing(
305
+ Options(
306
+ driverName="d",
307
+ packageNames=[PACKAGE_NAME],
308
+ propertytest_args=["discover", "-p", "Omninotes_Sample.py"],
309
+ serial=DEVICE_SERIAL,
310
+ running_mins=2,
311
+ maxStep=20
312
+ ),
313
+ configs_path = None # Default, if your configs folder is located in the root directory, miss this.
314
+ )
315
+
316
+ # restart your driver session or clean instance here
317
+ # ...
318
+
319
+ return # this make your following steps of this testcase not work
288
320
  ```
289
321
 
322
+
323
+
290
324
  ## Test Reports(测试报告)
291
325
 
292
326
  Kea2 automatically generates a HTML test report after each testing session. You can find the report in `output/` under your working directory.
@@ -11,8 +11,11 @@
11
11
 
12
12
  Please contact Xixian Liang at [xixian@stu.ecnu.edu.cn](xixian@stu.ecnu.edu.cn) with your Wechat ID / QR code to be invited to the WeChat discussion group. Of course, we are also ready on GitHub to answer your questions/feedback.
13
13
 
14
- ### Github repo link
15
- [https://github.com/ecnusse/Kea2](https://github.com/ecnusse/Kea2)
14
+ #### Github repo [https://github.com/ecnusse/Kea2](https://github.com/ecnusse/Kea2)
15
+ #### Gitee mirror [https://gitee.com/XixianLiang/Kea2](https://gitee.com/XixianLiang/Kea2)
16
+
17
+
18
+
16
19
 
17
20
  ### [点击此处:查看中文文档](README_cn.md)
18
21
 
@@ -193,7 +196,7 @@ You can find the full example in script `quicktest.py`, and run this script with
193
196
 
194
197
  ```bash
195
198
  # Launch Kea2 and load one single script quicktest.py.
196
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 200 --driver-name d propertytest discover -p quicktest.py
199
+ kea2 run -p it.feio.android.omninotes.alpha --running-minutes 10 --throttle 200 --driver-name d propertytest discover -p quicktest.py
197
200
  ```
198
201
 
199
202
  ## Feature 3(运行增强版Fastbot:加入自动断言)
@@ -228,7 +231,8 @@ For the preceding always-holding property, we can write the following script to
228
231
  )
229
232
  def test_input_box(self):
230
233
 
231
- # genenerate a random non-empty string (this is also property-based testing by feeding random text inputs!)
234
+ # genenerate a random non-empty string (this is also property-based testing
235
+ # by feeding random text inputs!)
232
236
  from hypothesis.strategies import text, ascii_letters
233
237
  random_str = text(alphabet=ascii_letters).example()
234
238
 
@@ -246,9 +250,7 @@ For the preceding always-holding property, we can write the following script to
246
250
 
247
251
  You can run this example by using the similar command line in Feature 2.
248
252
 
249
- ## Feature 4 (Experimental feature, 实验中,脚本与遍历的混合测试)
250
-
251
- > This feature is still under development. We are looking forward to your feedback! Contact us if you're interested in this feature.
253
+ ## Feature 4(兼容已有脚本:通过前置脚本步骤到达特定层次)
252
254
 
253
255
  Kea2 supports reusing existing Ui test Scripts. We are inspired by the idea that: *The existing Ui test scripts usually cover important app functionalities and can reach deep app states. Thus, they can be used as good "guiding scripts" to drive Fastbot to explore important and deep app states.*
254
256
 
@@ -256,22 +258,54 @@ For example, you may already have some existing Ui test scripts "login and add a
256
258
 
257
259
  ### Example
258
260
 
259
- See [guide_scripts.py](guide_scripts.py) for a full example.
261
+ Here are four example scripts in hybridetest_examples, each corresponding to different forms of user scripts, showing you how to launch kea2 in the existing code.
260
262
 
261
- By the decorator `@interruptable`, you can mark the testcase as "interruptable" so that Kea2 can recognize this script and launch fuzzing test after it returns.
263
+ Specifically:
262
264
 
263
- Since the state of app is probably unpredicted after fuzzing tests, Kea2 provides a `common_teardown` function to clean up the environment between previous script and next script. The function can be manually specified in `configs/teardown.py`.
265
+ * [u2_unittest_example.py](hybridtest_examples\u2_unittest_example.py) is a u2 script organized with unittest.
266
+ * [u2_pytest_example.py](hybridtest_examples\u2_pytest_example.py) is a u2 script organized with pytest.
267
+ * [appium_unittest_example.py](hybridtest_examples\appium_unittest_example.py) is an appium script organized with unittest.
268
+ * [appium_pytest_example.py](hybridtest_examples\appium_pytest_example.py) is an appium script organized with pytest.
264
269
 
265
- You can find the full example in `guide_scripts.py`, `property_omninotes.py` and `configs/teardown.py` . You can run one of the following commands:
270
+ Some notes:
266
271
 
267
- ```bash
268
- # Guide with guide_scripts.py and launch fuzzing test after every script.
269
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 500 --max-step 15 --driver-name d unittest discover -p guide_scripts.py
272
+ 1. You can control whether to execute the kea2-related code you have written by modifying the condition of 'if'. This allows you to easily enable or disable kea2 operations in the same script. Here we use environment variable as an example.
273
+ 2. Since kea2 is driven by u2, if an appium-written script wants to launch kea2, it is necessary to first close the appium session. Remember to configure the parameter `"noReset": True` in `desired_caps` to avoid resetting the application when closing the session.
274
+ 3. You need to insert the following code template into your existing test cases: Here, you can add your own hook logic in the commented sections, including starting or stopping the appium session, cleaning up instances, etc. This depends on how you want to design the setup and teardown. Apart from that, you only need to configure the `option` parameter and `configs_path` parameter(where your directory `configs` located, btw, `configs`'s location dependon where you executed `kea2 init`), then pass it to the `run_kea2_testing` function.
275
+
276
+ ```python
277
+ from kea2 import Kea2Tester, Options, U2Driver
270
278
 
271
- # Guide with guide_scripts.py and launch fuzzing test after every script(check properties during fuzzing).
272
- kea2 run -p it.feio.android.omninotes.alpha --agent u2 --running-minutes 10 --throttle 500 --max-step 15 --driver-name d unittest discover -p guide_scripts.py propertytest discover -p quickstart2.py
279
+ if os.environ.get('KEA2_HYBRID_MODE', '').lower() == 'true':
280
+ '''
281
+ Note: The if condition here can be modified as needed according to the actual
282
+ situation of the project, the form of environment variables is just an example.
283
+ '''
284
+
285
+ # close your driver session etc. here
286
+ # ...
287
+
288
+ tester = Kea2Tester()
289
+ result = self.tester.run_kea2_testing(
290
+ Options(
291
+ driverName="d",
292
+ packageNames=[PACKAGE_NAME],
293
+ propertytest_args=["discover", "-p", "Omninotes_Sample.py"],
294
+ serial=DEVICE_SERIAL,
295
+ running_mins=2,
296
+ maxStep=20
297
+ ),
298
+ configs_path = None # Default, if your configs folder is located in the root directory, miss this.
299
+ )
300
+
301
+ # restart your driver session or clean instance here
302
+ # ...
303
+
304
+ return # this make your following steps of this testcase not work
273
305
  ```
274
306
 
307
+
308
+
275
309
  ## Test Reports(测试报告)
276
310
 
277
311
  Kea2 automatically generates a HTML test report after each testing session. You can find the report in `output/` under your working directory.
@@ -0,0 +1,3 @@
1
+ from .keaUtils import KeaTestRunner, precondition, prob, max_tries, Options, interruptable,HybridTestRunner,kea2_breakpoint
2
+ from .kea2_api import Kea2Tester
3
+ from .u2Driver import U2Driver
@@ -95,13 +95,12 @@ def cmd_merge(args):
95
95
  # Merge test reports
96
96
  merged_report = merger.merge_reports(args.paths, args.output)
97
97
 
98
- # Print results
99
- print(f"✅ Test reports merged successfully!", flush=True)
100
- print(f"📊 Merged report: {merged_report}", flush=True)
101
-
102
- # Get merge summary
103
- merge_summary = merger.get_merge_summary()
104
- print(f"📈 Merged {merge_summary.get('merged_directories', 0)} directories", flush=True)
98
+ if merged_report is not None:
99
+ print(f"✅ Test reports merged successfully!", flush=True)
100
+ print(f"📊 Merged report: {merged_report}", flush=True)
101
+ # Get merge summary
102
+ merge_summary = merger.get_merge_summary()
103
+ print(f"📈 Merged {merge_summary.get('merged_directories', 0)} directories", flush=True)
105
104
 
106
105
  except Exception as e:
107
106
  logger.error(f"Error during merge operation: {e}")
@@ -41,62 +41,12 @@ class FastbotManager:
41
41
  :params: port: the listening port for script driver
42
42
  :return: the fastbot daemon thread
43
43
  """
44
- cur_dir = Path(__file__).parent
45
- self.dev.sync.push(
46
- Path.joinpath(cur_dir, "assets/monkeyq.jar"),
47
- "/sdcard/monkeyq.jar"
48
- )
49
- self.dev.sync.push(
50
- Path.joinpath(cur_dir, "assets/fastbot-thirdpart.jar"),
51
- "/sdcard/fastbot-thirdpart.jar",
52
- )
53
- self.dev.sync.push(
54
- Path.joinpath(cur_dir, "assets/kea2-thirdpart.jar"),
55
- "/sdcard/kea2-thirdpart.jar",
56
- )
57
- self.dev.sync.push(
58
- Path.joinpath(cur_dir, "assets/framework.jar"),
59
- "/sdcard/framework.jar",
60
- )
61
- self.dev.sync.push(
62
- Path.joinpath(cur_dir, "assets/fastbot_libs/arm64-v8a/libfastbot_native.so"),
63
- "/data/local/tmp/arm64-v8a/libfastbot_native.so",
64
- )
65
- self.dev.sync.push(
66
- Path.joinpath(cur_dir, "assets/fastbot_libs/armeabi-v7a/libfastbot_native.so"),
67
- "/data/local/tmp/armeabi-v7a/libfastbot_native.so",
68
- )
69
- self.dev.sync.push(
70
- Path.joinpath(cur_dir, "assets/fastbot_libs/x86/libfastbot_native.so"),
71
- "/data/local/tmp/x86/libfastbot_native.so",
72
- )
73
- self.dev.sync.push(
74
- Path.joinpath(cur_dir, "assets/fastbot_libs/x86_64/libfastbot_native.so"),
75
- "/data/local/tmp/x86_64/libfastbot_native.so",
76
- )
77
-
78
- cwd = getProjectRoot()
79
- whitelist = self.options.act_whitelist_file
80
- blacklist = self.options.act_blacklist_file
81
- if bool(whitelist) ^ bool(blacklist):
82
- if whitelist:
83
- file_to_push = cwd / 'configs' / 'awl.strings'
84
- remote_path = whitelist
85
- else:
86
- file_to_push = cwd / 'configs' / 'abl.strings'
87
- remote_path = blacklist
88
-
89
- self.dev.sync.push(
90
- file_to_push,
91
- remote_path
92
- )
93
44
 
45
+ self._push_libs()
94
46
  t = self._startFastbotService()
95
47
  logger.info("Running Fastbot...")
96
-
97
48
  return t
98
49
 
99
-
100
50
  def check_alive(self):
101
51
  """
102
52
  check if the script driver and proxy server are alive.
@@ -183,6 +133,58 @@ class FastbotManager:
183
133
  @property
184
134
  def device_output_dir(self):
185
135
  return self._device_output_dir
136
+
137
+ def _push_libs(self):
138
+ logger.info("Pushing Fastbot libraries to device...")
139
+ cur_dir = Path(__file__).parent
140
+ self.dev.sync.push(
141
+ Path.joinpath(cur_dir, "assets/monkeyq.jar"),
142
+ "/sdcard/monkeyq.jar"
143
+ )
144
+ self.dev.sync.push(
145
+ Path.joinpath(cur_dir, "assets/fastbot-thirdpart.jar"),
146
+ "/sdcard/fastbot-thirdpart.jar",
147
+ )
148
+ self.dev.sync.push(
149
+ Path.joinpath(cur_dir, "assets/kea2-thirdpart.jar"),
150
+ "/sdcard/kea2-thirdpart.jar",
151
+ )
152
+ self.dev.sync.push(
153
+ Path.joinpath(cur_dir, "assets/framework.jar"),
154
+ "/sdcard/framework.jar",
155
+ )
156
+ self.dev.sync.push(
157
+ Path.joinpath(cur_dir, "assets/fastbot_libs/arm64-v8a/libfastbot_native.so"),
158
+ "/data/local/tmp/arm64-v8a/libfastbot_native.so",
159
+ )
160
+ self.dev.sync.push(
161
+ Path.joinpath(cur_dir, "assets/fastbot_libs/armeabi-v7a/libfastbot_native.so"),
162
+ "/data/local/tmp/armeabi-v7a/libfastbot_native.so",
163
+ )
164
+ self.dev.sync.push(
165
+ Path.joinpath(cur_dir, "assets/fastbot_libs/x86/libfastbot_native.so"),
166
+ "/data/local/tmp/x86/libfastbot_native.so",
167
+ )
168
+ self.dev.sync.push(
169
+ Path.joinpath(cur_dir, "assets/fastbot_libs/x86_64/libfastbot_native.so"),
170
+ "/data/local/tmp/x86_64/libfastbot_native.so",
171
+ )
172
+
173
+ cwd = getProjectRoot()
174
+ whitelist = self.options.act_whitelist_file
175
+ blacklist = self.options.act_blacklist_file
176
+ if bool(whitelist) ^ bool(blacklist):
177
+ if whitelist:
178
+ file_to_push = cwd / 'configs' / 'awl.strings'
179
+ remote_path = whitelist
180
+ else:
181
+ file_to_push = cwd / 'configs' / 'abl.strings'
182
+ remote_path = blacklist
183
+
184
+ self.dev.sync.push(
185
+ file_to_push,
186
+ remote_path
187
+ )
186
188
 
187
189
  def _startFastbotService(self) -> ADBStreamShell_V2:
188
190
  shell_command = [