|
| 1 | +# Testing |
| 2 | + |
| 3 | +## For Users of the TEN Framework |
| 4 | + |
| 5 | +(To be added.) |
| 6 | + |
| 7 | +## For Developers of the TEN Framework |
| 8 | + |
| 9 | +The TEN framework includes three types of test suites: |
| 10 | + |
| 11 | +* Unit Tests |
| 12 | +* Smoke Tests |
| 13 | +* Integration Tests |
| 14 | + |
| 15 | +The TEN framework uses `gtest` as the testing framework for unit tests and smoke tests, and `pytest` as the testing framework for integration tests. |
| 16 | + |
| 17 | +### Unit Tests |
| 18 | + |
| 19 | +The source directory for unit tests is `test/ten_runtime/unit`. If you need to add new unit test cases, please place them in the `test/ten_runtime/unit directory`. |
| 20 | + |
| 21 | +For C++ projects, after successful compilation, you can navigate to the output directory (e.g., `out/linux/x64/test/standalone/`, depending on the target OS and CPU) and execute the following command: |
| 22 | + |
| 23 | +``` shell |
| 24 | +./ten_runtime_unit_test |
| 25 | +``` |
| 26 | + |
| 27 | +### Smoke Tests |
| 28 | + |
| 29 | +The source directory for smoke tests is `test/ten_runtime/smoke`. If you need to add new smoke test cases, please place them in the `test/ten_runtime/smoke` directory. |
| 30 | + |
| 31 | +Navigate to the output directory (e.g., `out/linux/x64/test/standalone`, depending on the target OS and CPU) and execute the following command: |
| 32 | + |
| 33 | +``` shell |
| 34 | +./ten_runtime_smoke_test |
| 35 | +``` |
| 36 | + |
| 37 | +### Loop Testing |
| 38 | + |
| 39 | +You can perform multiple rounds of testing using the following commands. |
| 40 | + |
| 41 | +To run only unit tests: |
| 42 | + |
| 43 | +``` shell |
| 44 | +failed=0; for i in {1..100}; do if [ ${failed} != 0 ]; then echo "error occurred:" ${failed}; break; fi; ./ten_runtime_unit_test; failed=$?; done; |
| 45 | +``` |
| 46 | + |
| 47 | +To run only smoke tests: |
| 48 | + |
| 49 | +``` shell |
| 50 | +failed=0; for i in {1..100}; do if [ ${failed} != 0 ]; then echo "error occurred:" ${failed}; break; fi; ./ten_runtime_smoke_test; failed=$?; done; |
| 51 | +``` |
| 52 | + |
| 53 | +To run both unit tests and smoke tests: |
| 54 | + |
| 55 | +``` shell |
| 56 | +failed=0; for i in {1..100}; do if [ ${failed} != 0 ]; then echo "error occurred:" ${failed}; break; fi; ./ten_runtime_unit_test; failed=$?; if [ ${failed} != 0 ]; then echo "error occurred:" ${failed}; break; fi; ./ten_runtime_smoke_test; failed=$?; done; |
| 57 | +``` |
| 58 | + |
| 59 | +### Integration Tests |
| 60 | + |
| 61 | +Integration tests are black-box tests for the TEN framework. The source directory for integration tests is `test/ten_runtime/integration`. These tests are used to validate real-world execution scenarios. |
| 62 | + |
| 63 | +The file structure for integration tests is as follows: |
| 64 | + |
| 65 | +``` text |
| 66 | +test/ten_runtime/integration/ |
| 67 | + ├── test_1/ |
| 68 | + │ ├── test_case.py |
| 69 | + │ └── ... |
| 70 | + ├── test_2/ |
| 71 | + │ ├── test_case.py |
| 72 | + │ └── ... |
| 73 | + └── ... |
| 74 | +``` |
| 75 | + |
| 76 | +To execute the integration tests, use the following command: |
| 77 | + |
| 78 | +``` shell |
| 79 | +cd path/to/out/ |
| 80 | +pytest test/ten_runtime/integration/ |
| 81 | +``` |
0 commit comments