summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Wang <[email protected]>2025-08-26 10:59:30 +0800
committerR b b666 <[email protected]>2025-08-26 11:06:02 +0800
commit98cb15a3ef2cddfaa69272778d9a7e184834d6d0 (patch)
tree0643ac7b119be7ca05adcb093df784804c3d7540
parent0fdeb4c077cbae07453dc2de9a57f9d5cf6fc2c5 (diff)
doxygen: add howto for utest
After "utest: re-org utest framework (initial version)" (PR #10534) was merged, adding a document to introduce how to add utest-cases for your module. Signed-off-by: Chen Wang <[email protected]>
-rw-r--r--documentation/6.components/utest/utest.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/documentation/6.components/utest/utest.md b/documentation/6.components/utest/utest.md
index 9580fcb2b7..dffff28535 100644
--- a/documentation/6.components/utest/utest.md
+++ b/documentation/6.components/utest/utest.md
@@ -272,3 +272,24 @@ From the above flow chart you can get the following:
- The resources (threads, semaphores, timers, memory, etc.) created in the test case need to be released before the test ends.
- A test case implementation can only export a test body function (testcase function) using `UTEST_TC_EXPORT`
- Write a `README.md` document for the your test case to guide the user through configuring the test environment.
+
+# How-to add utest cases into RT-Thread for your module.
+
+The source code of utest cases is recommended to be placed in each module for maintenance, but the entry of Kconfig should all be placed(rsourced) in `Kconfig.utestcases` for unified maintenance. In this way, when executing menuconfig, people can enter and configure from one place, avoiding searching for utest configuration switches scattering in the menuconfig interface.
+
+For each module, you can maintain unit testcases in a unified manner in the following way:
+
+- Create a subdirectory named 'utest' in the directory where your module is located.
+
+- Store the following files in the 'utest' subdirectory:
+
+ - Unit-testcase program source code files for this module.
+
+ - `Kconfig` file, which defining configuration options for the unit test cases of this module, the recommended option is named `RT_UTEST_TC_USING_XXXX`, XXXX is the global unique module name of this module.
+
+ - `SConscript` file, note that when adding src files, in addition to relying on `RT_UTEST_TC_USING_XXXX`, you must also rely on `RT_UTEST_USING_ALL_CASES`, the two dependencies are in an "or" relationship. The role of `RT_UTEST_USING_ALL_CASES` is that once this option is turned on, all unit-testcases will be enabled to avoid selecting one by one.
+
+After completing the above steps, rsource the path of the Kconfig file of utest of this module to the file `Kconfig.utestcases`.
+
+You can find a good example in <a href="https://github.com/RT-Thread/rt-thread/blob/master/src/klibc/utest/">"klibc"</a>.
+