Dynamic functions¶
Sphinx-Test-Reports provides dynamic functions for Sphinx-Needs.
Read chapter Dynamic function from Sphinx-Needs documentation to know how to use them.
tr_link¶
Links a need (e.g testcase) automatically to other needs, which have a specific value in a given option.
Usage:
.. test-case:: My test case
:id: TESTCASE_1
:file: my_test_file.xml
:suite: pytest
:classname: sphinxcontrib.test_reports.test_reports
:case: FLAKE8
:links: [[tr_link("source_option", "target_option")]]
tr_link needs the following arguments:
source_option: Name of an option of the test-need, which is used for comparision. E.g.
classname.target_option: Name of an option of all other needs, which is used for comparision. E.g.
title.
The function reads the target_option from the need, where it is used.
Then it goes through all other needs and checks if the value of their source_option is equal to
the target_option.
If this is the case, their IDs get stored and finally returned.
source_option can also reference an option with comma separated values.
In this case a comparions is performed for each value, which may lead to multiple links.
Example:
.. spec:: sphinxcontrib.test_reports.test_reports
:id: TESTSPEC_001
:status: open
:tags: example, link_example
This specification specifies the test case ``sphinxcontrib.test_reports.test_reports``.
.. test-case:: Flake8 test case
:id: TESTLINK_1
:file: ../tests/doc_test/utils/pytest_data.xml
:suite: pytest
:classname: sphinxcontrib.test_reports.test_reports
:case: FLAKE8
:tags: example, link_example
:links: [[tr_link('classname', 'title')]]
A simple test case.
We will set a link to the need, which has our classname as title.
.. needflow::
:tags: link_example
This specification specifies the test case |
A simple test case. We will set a link to the need, which has our classname as title. Text: Message: |
![@startuml
' Nodes definition
node "<size:12>Specification</size>\n**sphinxcontrib.t**\n**est_reports.tes**\n**t_reports**\n<size:10>TESTSPEC_001</size>" as TESTSPEC_001 [[../functions.html#TESTSPEC_001]] #FEDCD2
rectangle "<size:12>Test-Case</size>\n**Flake8 test**\n**case**\n<size:10>TESTLINK_1</size>" as TESTLINK_1 [[../functions.html#TESTLINK_1]] #999999
' Connection definition
TESTLINK_1 --> TESTSPEC_001
@enduml](_images/plantuml-b3ff6b35290b546df6ffe287bd0f9d7d79f89eac.png)