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
This guide demonstrates how to integrate test reports into your documentation with full traceability between test specifications, test cases, source code, and test results.
10
+
This guide demonstrates how to integrate test reports into your
11
+
documentation with full traceability between test specifications, test
12
+
cases, source code, and test results.
13
13
14
14
Overview
15
15
--------
@@ -22,12 +22,14 @@ A comprehensive testing approach includes:
22
22
* **Traceability**: Links between all these elements
23
23
* **Test Reports**: Results from test execution
24
24
25
-
By using Sphinx-Needs for test specifications, sphinx-codelinks for code tracing, and sphinx-test-reports for test results, we create a complete traceable testing ecosystem.
25
+
By using Sphinx-Needs for test specifications, sphinx-codelinks for
26
+
code tracing, and sphinx-test-reports for test results, we create a
27
+
complete traceable testing ecosystem.
26
28
27
29
Workflow
28
30
--------
29
31
30
-
.. mermaid::
32
+
.. mermaid::
31
33
32
34
graph LR
33
35
REQ[Requirements] --> TS[Test Specifications]
@@ -36,7 +38,7 @@ Workflow
36
38
TC --> RUN[Test Execution]
37
39
RUN --> REPORT[Test Reports]
38
40
REPORT --> DOC[Documentation]
39
-
41
+
40
42
style REQ fill:#FFB300
41
43
style TS fill:#A6BDD7
42
44
style TC fill:#A6BDD7
@@ -45,40 +47,44 @@ Workflow
45
47
style DOC fill:#F6768E
46
48
47
49
Step 1: Define Test Specifications
48
-
-----------------------------------
50
+
----------------------------------
49
51
50
-
Create test specifications using the ``test-spec`` directive to define what needs to be tested:
52
+
Create test specifications using the ``test-spec`` directive to define
53
+
what needs to be tested:
51
54
52
55
.. test-spec:: Factorial Function Test Specification
Copy file name to clipboardExpand all lines: docs/how-to-guides/trace-code/index.rst
+39-29Lines changed: 39 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,76 +3,86 @@
3
3
:octicon:`link` Tracing Source Code
4
4
===================================
5
5
6
-
This guide explains how to use CodeLinks to trace source code files and lines to needs in your documentation.
6
+
This guide explains how to use CodeLinks to trace source code files
7
+
and lines to needs in your documentation.
7
8
8
9
**Step 1: Install CodeLinks**
9
10
10
11
Follow the installation instructions in the `CodeLinks documentation <https://codelinks.useblocks.com/basics/installation.html>`__.
11
12
12
13
**Step 2: Configure CodeLinks**
13
14
14
-
Create a file named ``src_trace.toml`` in your ``docs`` folder (next to ``conf.py``) with the following content:
15
+
Create a file named ``src_trace.toml`` in your ``docs`` folder (next
16
+
to ``conf.py``) with the following content:
15
17
16
18
.. literalinclude:: ../../src_trace.toml
17
-
:language: toml
18
-
:caption: src_trace.toml
19
+
:language: toml
20
+
:caption: src_trace.toml
19
21
20
22
**Step 3: Add the src-trace Directive**
21
23
22
-
In your documentation files, add the following directive to display traced source code links:
24
+
In your documentation files, add the following directive to display
25
+
traced source code links:
23
26
24
27
.. code-block:: rst
25
28
26
-
.. src-trace::
27
-
:project: eac-cpp
28
-
:directory: .
29
+
.. src-trace::
30
+
:project: x-as-code-cpp
31
+
:directory: .
29
32
30
33
**Step 4: Annotate Your Source Code**
31
34
32
-
Add comments to your source code files to link code lines to needs. For example, in ``src/main.cpp``:
35
+
Add comments to your source code files to link code lines to needs.
36
+
For example, in ``src/main.cpp``:
33
37
34
38
.. literalinclude:: ../../../src/main.cpp
35
-
:language: cpp
36
-
:caption: src/main.cpp
39
+
:language: cpp
40
+
:caption: src/main.cpp
37
41
38
42
**Step 5: View Traced Files and Lines**
39
43
40
-
After following the steps above, the documentation will show the traced files and lines for each need in the specified project (``eac-cpp``). Here we show only the implementation files (not test files):
44
+
After following the steps above, the documentation will show the
45
+
traced files and lines for each need in the specified project (``x-as-code-cpp``).
46
+
Here we show only the implementation files (not test files):
41
47
42
-
.. src-trace::
43
-
:project:eac-cpp
44
-
:file: main.cpp
48
+
.. src-trace::
49
+
:project:x-as-code-cpp
50
+
:file: main.cpp
45
51
46
-
.. src-trace::
47
-
:project:eac-cpp
48
-
:file: sample1.cpp
52
+
.. src-trace::
53
+
:project:x-as-code-cpp
54
+
:file: sample1.cpp
49
55
50
-
.. src-trace::
51
-
:project:eac-cpp
52
-
:file: sample2.cpp
56
+
.. src-trace::
57
+
:project:x-as-code-cpp
58
+
:file: sample2.cpp
53
59
54
-
**Note**: Test files are traced separately in the :ref:`testing guide <testing>` to avoid duplicate need IDs.
60
+
**Note**: Test files are traced separately in the :ref:`testing guide <testing>`
61
+
to avoid duplicate need IDs.
55
62
56
63
**Summary**
57
64
58
-
By following these steps, you can easily trace source code to requirements, improving traceability and documentation quality.
65
+
By following these steps, you can easily trace source code to
66
+
requirements, improving traceability and documentation quality.
59
67
60
68
Advanced configuration options and features are available in the `CodeLinks documentation <https://codelinks.useblocks.com/components/configuration.html>`__.
61
69
62
70
Linking Requirements to Code
63
-
-----------------------------
71
+
----------------------------
64
72
65
73
Finally you can link from/to the traced source code lines like this:
66
74
67
75
.. req:: Requirement linking to source code
68
76
:id: REQ_0815
69
77
:status: open
70
78
71
-
This is a requirement that links to a need that has traced source code lines.
79
+
This is a requirement that links to a need that has traced source code
80
+
lines.
72
81
73
82
.. note::
74
83
75
-
Current limitation: ``ubCode`` is not aware of this need id yet. This means that
76
-
the ``ubCode`` navigation inside Visual Studio Code will not work and jumping from
77
-
this ``rst`` file to the source code line will not work. This will be implemented
78
-
and supported in a future release.
84
+
Current limitation: ``ubCode`` is not aware of this need id yet. This
85
+
means that the ``ubCode`` navigation inside Visual Studio Code will
86
+
not work and jumping from this ``rst`` file to the source code line
87
+
will not work. This will be implemented and supported in a future
0 commit comments