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
``idf_parametrize`` is a wrapper around ``pytest.mark.parametrize`` that simplifies and extends string-based parameterization for tests. By using ``idf_parametrize``, testing parameters becomes more flexible and easier to maintain.
70
+
71
+
**Key Features:**
72
+
73
+
- **Target Expansion**: Automatically expands lists of supported targets, reducing redundancy in test definitions.
74
+
- **Markers**: use a marker as one of the parameters. If a marker is used, put it as the last parameter.
75
+
76
+
Use Cases
77
+
=========
78
+
79
+
Target Extension
80
+
----------------
81
+
82
+
In scenarios where the supported targets are [esp32, esp32c3, esp32s3], ``idf_parametrize`` simplifies the process of creating parameterized tests by automatically expanding the target list.
83
+
84
+
**Example:**
85
+
86
+
.. code:: python
87
+
88
+
@idf_parametrize('target', [
89
+
('supported_targets'),
90
+
], indirect=True)
91
+
@idf_parametrize('config', [
92
+
'default',
93
+
'psram'
94
+
])
95
+
deftest_st(dut: Dut) -> None:
96
+
...
97
+
98
+
**Equivalent to:**
99
+
100
+
.. code:: python
101
+
102
+
@pytest.mark.parametrize('target', [
103
+
'esp32',
104
+
'esp32c3',
105
+
'esp32s3'
106
+
], indirect=True)
107
+
@pytest.mark.parametrize('config', [
108
+
'default',
109
+
'psram'
110
+
])
111
+
deftest_st(dut: Dut) -> None:
112
+
...
113
+
114
+
**Resulting Parameters Matrix:**
115
+
116
+
.. list-table::
117
+
:header-rows: 1
118
+
119
+
- - Target
120
+
- Config
121
+
- - esp32
122
+
- default
123
+
- - esp32c3
124
+
- default
125
+
- - esp32s3
126
+
- default
127
+
- - esp32
128
+
- psram
129
+
- - esp32c3
130
+
- psram
131
+
- - esp32s3
132
+
- psram
133
+
134
+
Markers
135
+
-------
136
+
137
+
Markers can also be combined for added flexibility. It must be placed in the last position. In this case, if some test cases do not have markers, you can skip their definition. Look at the example.
138
+
139
+
**Example:**
140
+
141
+
In IDF testing, an environment marker (``marker``) determines which test runner will execute a test. This enables tests to run on various runners, such as:
142
+
143
+
- **generic**: Tests run on generic runners.
144
+
- **sdcard**: Tests require an SD card runner.
145
+
- **usb_device**: Tests require a USB device runner.
0 commit comments