You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<td>Copy the unit test app in the current project, build the current project. More information in <a href="https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/additionalfeatures/unit-testing.html">Unit testing documentation</a>.</td>
448
448
<td></td>
449
449
<td></td>
450
450
</tr>
451
451
<tr>
452
-
<td rowspan=2 align="center">Unit Testing</td>
453
452
<td>Unit Test: Flash Unit Test App</td>
454
453
<td>Flash the unit test application to the connected device. More information in <a href="https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/additionalfeatures/unit-testing.html">Unit testing documentation</a>.</td>
455
454
<td></td>
456
455
<td></td>
457
456
</tr>
458
457
<tr>
459
-
<td rowspan=2 align="center">Unit Testing</td>
460
458
<td>Unit Test: Build and Flash Unit Test App for Testing</td>
461
459
<td>Copy the unit test app in the current project, build the current project and flash the unit test application to the connected device. More information in <a href="https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/additionalfeatures/unit-testing.html">Unit testing documentation</a>.</td>
<td>Install the ESP-IDF Pytest requirement packages to be able to execute ESP-IDF unit tests. More information in <a href="https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/additionalfeatures/unit-testing.html">Unit Testing documentation</a>.</td>
468
-
<td></td>
469
-
<td></td>
470
-
</tr>
471
463
<tr>
472
464
<td rowspan=10 align="center">Scripts and Tools</td>
Copy file name to clipboardExpand all lines: docs_espressif/en/additionalfeatures/unit-testing.rst
+9-53Lines changed: 9 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,64 +41,20 @@ To add tests for a ``testable`` component, define a ``test`` subdirectory and ad
41
41
42
42
This structure is from the `ESP-IDF unit_test example <https://github.com/espressif/esp-idf/tree/master/examples/system/unit_test>`_, which can serve as a reference.
43
43
44
-
.. note::
45
-
46
-
You can customize the test file discovery pattern by modifying the ``idf.unitTestFilePattern`` setting in your VS Code settings. This allows you to use different naming conventions or directory structures for your test files.
47
-
48
-
pytest Embedded Services Configuration
49
-
--------------------------------------
50
-
51
-
The extension uses `pytest-embedded <https://docs.espressif.com/projects/pytest-embedded/en/latest/index.html>`_ to run tests on ESP-IDF devices. The ``idf.pyTestEmbeddedServices`` configuration setting allows you to specify which embedded services to use when running pytest commands.
52
-
53
-
By default, the extension uses ``["esp", "idf"]`` as the embedded services. These services provide the following functionality:
54
-
55
-
* **esp**: Enables Espressif-specific functionality, including automatic target detection and port confirmation using ``esptool``.
56
-
* **idf**: Provides ESP-IDF project support, including automatic flashing of built binaries and parsing of binary information.
57
-
58
-
You can customize the embedded services by modifying the ``idf.pyTestEmbeddedServices`` setting in your VS Code settings. For example, you might want to add following additional services:
59
-
60
-
* **serial**: For basic serial port communication.
61
-
* **jtag**: For OpenOCD/GDB utilities.
62
-
* **qemu**: For running tests on QEMU instead of real hardware.
63
-
* **wokwi**: For running tests on the Wokwi simulation platform.
64
-
65
-
For a complete list of available services and their capabilities, refer to the `pytest-embedded Services Documentation <https://docs.espressif.com/projects/pytest-embedded/en/latest/concepts/services.html>`_.
66
-
67
-
.. note::
68
-
69
-
The embedded services you choose will affect the pytest command that gets executed. Make sure the services you specify are compatible with your testing environment and requirements.
70
-
71
-
Running the Tests
72
-
-----------------
44
+
Running the tests
45
+
--------------------------------------------
73
46
74
47
When you click the ``Testing`` Tab in the `Visual Studio Code Activity bar <https://code.visualstudio.com/docs/getstarted/userinterface>`_, the extension will try to find all test files and test cases and save the list of test components to add later in step 3.
75
48
76
-
.. note::
77
-
78
-
User needs to install ESP-IDF pytest Python requirements by selecting menu ``View`` > ``Command Palette`` and typing ``Unit Test: Install ESP-IDF pytest requirements``. Select the command and see the pytest package installation output.
79
-
80
-
When you press the ``run`` button on a test, it will configure the current project before the tests as follows:
81
-
82
-
1. Check that pytest requirements from ESP-IDF are satisfied.
83
-
84
-
.. note::
85
-
86
-
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.
49
+
When it press the run button on a test, it will configure the current project before the tests as follows:
87
50
88
-
2. Install ESP-IDF pytest requirements if they are not found in the python current virtual environment specified in ``idf.toolsPath`` configuration setting in ``settings.json``.
51
+
1. 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.
89
52
90
-
3. Copy the ``unity-app`` from the extension template, and add the required test components to the ``TEST_COMPONENTS`` CMake variable in the main ``CMakeLists.txt``. The ``unity-app`` provided by the extension is a simple ESP-IDF application that includes a Unity menu. It will be built and flashed to the serial device defined by ``idf.port``, together with all the test cases discovered during the exploration step.
53
+
2. Build and flash the unity-appto the device.
91
54
92
-
.. note::
93
-
94
-
You can also create, build and flash the unity test application using the ``Unit Test: Install ESP-IDF pytest requirements`` extension command, which will copy, build, and flash the generated unit testing application to your device.
95
-
96
-
4. Run `pytest-embedded <https://docs.espressif.com/projects/pytest-embedded/en/latest/index.html>`_, a plugin that extends pytest to run on ESP-IDF devices and output the results as an XML file in the ``unity-app`` directory. This is executed as an extension task, and the output is shown in the terminal (similar to build and flash tasks). The pytest command uses the embedded services specified in the ``idf.pyTestEmbeddedServices`` configuration setting (default: ``["esp", "idf"]``).
97
-
98
-
.. note::
99
-
100
-
You can customize the embedded services used by pytest by modifying the ``idf.pyTestEmbeddedServices`` setting in your VS Code settings. This allows you to specify different services or add additional ones as needed for your testing environment.
55
+
.. note::
56
+
You can also create, build and flash the unity test application using the **ESP-IDF Unit Test: Build Unit Test App** and **ESP-IDF Unit Test: Flash Unit Test App** extension commands respectively, which will copy build and flash to your device the generated unit testing application.
101
57
102
-
5. The XML results file is parsed, and test results are updated in the ``Testing`` tab with test duration.
58
+
3. Capture the serial output from the device and parse the test results to show them in the ``Testing`` tab. The output from serial port is also shown in the ``ESP-IDF`` output channel.
103
59
104
-
6. You can refresh the tests and build the ``unity-app`` again with the ``Refresh Tests`` button from the ``Testing`` tab.
60
+
4. You can refresh the tests and build the unity-app again with the ``Refresh Tests`` button from the ``Testing`` tab.
Copy file name to clipboardExpand all lines: docs_espressif/en/commands.rst
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,5 +136,3 @@ All commands start with ``ESP-IDF:``.
136
136
- Flash the unit test application for the current project to the connected device. More information can be found in :ref:`Unit Testing Documentation <unit testing>`.
137
137
* - Unit Test: Build and Flash Unit Test App for Testing
138
138
- Copy the unit test app in the current project, build the current project and flash the unit test application to the connected device. More information can be found in :ref:`Unit Testing Documentation <unit testing>`.
139
-
* - Unit Test: Install ESP-IDF Pytest Requirements
140
-
- Install the ESP-IDF Pytest requirement packages to be able to execute ESP-IDF unit tests. More information can be found in :ref:`Unit Testing Documentation <unit testing>`.
0 commit comments