Skip to content

Conversation

Shen7436
Copy link
Collaborator

This PR:

Resubmits #1651 from my previous account, which is no longer accessible.

Adjusts some format issues and unclear expressions for unit-testing.rst based on Espressif Style Guide
Provides CN translation for unit-testing.rst
TODO: Closes DOC-12102 once merged

@Shen7436 Shen7436 self-assigned this Sep 17, 2025
@Shen7436 Shen7436 added the documentation 📝 Solely about the documentation of the project. label Sep 17, 2025
@Shen7436
Copy link
Collaborator Author

Hi @zztiger123 @April-Yjj PTAL, thx!

PS Content in this PR has already been technically reviewed in the old PR.

Copy link

Download the artifacts for this pull request:
You can test these changes by installing this VSIX by click menu View -> Command Palette..., type Install from VSIX and then select downloaded esp-idf-extension.vsix file to install the extension.

.. note::

3. Copy the unity-app from the extension template and add the test components to the main CMakeLists.txt ``TEST_COMPONENTS`` cmake variable. The extension unity-app is a basic ESP-IDF application with a unity menu that will be built and flashed on the current **idf.port** serial device with all test cases that were found during exploration step.
Unit tests in this extension requires `ESP-IDF pytest requirements <https://github.com/espressif/esp-idf/blob/master/tools/requirements/requirements.pytest.txt>`_ to be installed in your Python virtual environment.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brianignacio5 This link leads to a 404 page, pls help fix, thx~

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems ESP-IDF changed the way pytest is installed and defined. This would require a bigger change on the vscode extension.

@April-Yjj
Copy link

Hi @Shen7436 Just saw 2 warnings in the building log. Would you fix them and submit again? Thanks a lot!

@Shen7436
Copy link
Collaborator Author

@April-Yjj The warnings have already been resolved. However, this PR skipped all CI checks, and I’m not sure why.

Copy link

@April-Yjj April-Yjj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Shen7436 Thansk for your translation! Left a few comments. Overall LGTM.


.. note::
您也可以使用 **ESP-IDF 单元测试:安装 ESP-IDF PyTest 要求** 扩展命令创建、构建和烧录 unity 测试应用程序,该命令将复制构建并烧录生成的单元测试应用程序到您的设备。
2. 如果在 ``settings.json`` 文件中 ``idf.toolsPath`` 配置项所指定的 Python 虚拟环境中未找到 ESP-IDF 所需的 pytest 依赖,则系统会自动安装这些依赖。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前面说“运行命令安装依赖”,这句是不是想说,如果未找到依赖则需要手动安装?现在翻译的是如果未找到依赖会自动安装,有点不符合常理。原文里暂时没找到自动安装的意思,可能需要确认一下

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“When you press the run button on a test, it will configure the current project before the tests as follows:” 这里的 it 就是指系统吧。相当于 "run" 这个 button 就是一个触发,可以检查所有必要的安装项目,如果发现没安装,就会自动装上。和下面第三条内容的note是呼应的。所有没有通过命令手动安装的配置都会触发”run“之后被安装。

2. 如果在 ``settings.json`` 文件中 ``idf.toolsPath`` 配置项所指定的 Python 虚拟环境中未找到 ESP-IDF 所需的 pytest 依赖,则系统会自动安装这些依赖。

4. 运行 `pytest-embedded <https://docs.espressif.com/projects/pytest-embedded/en/latest/index.html>`_,这是一个扩展 PyTest 以在 esp-idf 设备上运行的插件,并在 unity-app 目录中以 XML 文件形式输出结果。这作为扩展任务执行,输出显示在终端中(类似于构建和烧录任务)。pytest 命令使用 **idf.pyTestEmbeddedServices** 配置设置中指定的嵌入式服务(默认:``["esp", "idf"]``)
3. 从扩展模板中复制 ``unity-app``,并将所需的测试组件添加到主 ``CMakeLists.txt`` 文件的 ``TEST_COMPONENTS`` CMake 变量中。扩展提供的 ``unity-app`` 是一个包含单元测试菜单的简单 ESP-IDF 应用程序,且会被构建并烧录到 ``idf.port`` 指定的串口设备上,同时运行所有发现的测试用例

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 单元测试 -> Unity 测试。这里是 Unity 不是 unit. Please check globally.
  • 看原文和下文 note 的意思,测试用例在这里仅仅是被构建和烧录,而不是运行。Please confirm.
Suggested change
3. 从扩展模板中复制 ``unity-app``,并将所需的测试组件添加到主 ``CMakeLists.txt`` 文件的 ``TEST_COMPONENTS`` CMake 变量中。扩展提供的 ``unity-app`` 是一个包含单元测试菜单的简单 ESP-IDF 应用程序,且会被构建并烧录到 ``idf.port`` 指定的串口设备上,同时运行所有发现的测试用例
3. 从扩展模板中复制 ``unity-app``,并将所需的测试组件添加到主 ``CMakeLists.txt`` 文件的 ``TEST_COMPONENTS`` CMake 变量中。扩展提供的 ``unity-app`` 是一个包含 Unity 测试菜单的简单 ESP-IDF 应用程序,该程序会和探索步骤中发现的测试用例一起,构建并烧录到 ``idf.port`` 指定的串口设备上。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📝 Solely about the documentation of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants