useblocks / sphinx-test-reports

Documents test-results inside Sphinx
https://sphinx-test-reports.readthedocs.io/en/latest/
MIT License
28 stars 18 forks source link

How to configure the `tr_link` dynamic function to match a `classname` and a `casename` #35

Open santiagopagani opened 2 years ago

santiagopagani commented 2 years ago

Hi,

I would like to know if test_reports currently supports our use case. Namely, we have multiple software requirements, where each requirement usually matches a method of a class. For example, let's say, we have ClassA with methods get() and set(), and we then have ReqA_get, and ReqA_set.

For testing we use GTest, and we normally have a test file with a test class that tests an entire class. For example, we would have GTest class TestClassA for testing ClassA. The test involves multiple test functions, where multiple test functions are involved in testing a method of ClassA. For example, we would have TestClassA_get_1, and TestClassA_get_2 for test method get() of ClassA, and we would have TestClassA_set_1, TestClassA_set_2, and TestClassA_set_3 for testing method set() of ClassA. We then define the Test Specification in such a way that we have one specification per test.

The xml output from GTest for the test cases would be (summarizing only the class name and case name): classname="TestClassA" and name="get_1" classname="TestClassA" and name="get_2" classname="TestClassA" and name="set_1" classname="TestClassA" and name="set_2" classname="TestClassA" and name="set_3"

So far, by having a configuration as for example

needs_global_options = {
    'tests': "[[tr_link('classname', 'title')]]",
}

we need to have the same name as the test class in all test specifications, e.g., .. test:: TestClassA, and we would get ALL test cases in the test file TestClassA linked to every test specification. However, we would like to have each test case only linked with its corresponding test specification.

One way to do this would be to adapt the tr_link function such that it could take a tupple of multiple things that need to be matched. We could then add classname and casename to the test specification and then have both things matched to the xml.

Thank you for the great work.

cuinixam commented 8 months ago

Hi, I also find the idea of a global configuration very useful. Currently, to link test cases with test results, we have to add :results: [[tr_link('title', 'case')]] to all the GTest test cases. I would be willing to implement this feature if this discussion leads to something concrete.

cuinixam commented 8 months ago

I have just realised that the needs_global_options actually exists 😮 Sorry! As for linking multiple tests results to test cases, hopefully #68 will get through.