File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
contributing/development/core_and_modules Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,26 @@ common test data for each test, or writing parameterized tests.
152152Godot supports writing tests per C++ module. For instructions on how to write
153153module tests, refer to :ref: `doc_custom_module_unit_tests `.
154154
155+ Subcases
156+ ~~~~~~~~
157+
158+ In situations where you have a common setup for several test cases with only slight variations, subcases can be very helpful. Here's an example:
159+
160+ .. code-block :: cpp
161+
162+ TEST_CASE("[SceneTree][Node] Testing node operations with a very simple scene tree") {
163+ // ... common setup (e.g. creating a scene tree with a few nodes)
164+ SUBCASE("Move node to specific index") {
165+ // ... setup and checks for moving a node
166+ }
167+ SUBCASE("Remove node at specific index") {
168+ // ... setup and checks for removing a node
169+ }
170+ }
171+
172+ Each ``SUBCASE `` causes the ``TEST_CASE `` to be executed from the beginning.
173+ Subcases can be nested to an arbitrary depth, but it is advised to limit nesting to no more than one level deep.
174+
155175Assertions
156176~~~~~~~~~~
157177
You can’t perform that action at this time.
0 commit comments