Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(junit): record app_path in JUnit reports #336

Conversation

alekseiapa
Copy link
Collaborator

Description

This PR introduces the feature to record attribute app_path in JUnit reports.

Related

Closes #332

Testing

Added test that ensures that the app_path attribute is correctly recorded for each <testcase> element in the JUnit report.


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@alekseiapa alekseiapa requested a review from hfudev January 22, 2025 06:36
@alekseiapa
Copy link
Collaborator Author

Hi @hfudev . Please take a look at the changes. Thanks!

@alekseiapa alekseiapa force-pushed the fix/add-app-path-to-junit-report-suite branch from 124b8bc to 0650486 Compare January 22, 2025 07:06
@horw
Copy link
Member

horw commented Jan 23, 2025

Shall we also add a test for test_idf.py to ensure it works with apps?

@alekseiapa alekseiapa force-pushed the fix/add-app-path-to-junit-report-suite branch 2 times, most recently from 2a95e62 to 381db08 Compare January 23, 2025 05:57
Copy link
Member

@hfudev hfudev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall LGTM. a few comments posted

pytest-embedded/pytest_embedded/plugin.py Outdated Show resolved Hide resolved
Comment on lines +330 to +333
# Add the 'pytest_case_name' attribute for each test case to enable later extraction
# of the app_path from the pytest_case_name to app_path mapping
if 'pytest_case_name' not in testcase.attrib:
testcase.attrib['pytest_case_name'] = testcase.attrib.get('name')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question, why can't we use the attrib['name'] here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that in some cases, the pytest test case name is being replaced by the C test case name, resulting in the name being absent in the mapping.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. so I have a different implementation of the whole task.

single-dut test cases

instead of your current modify main junit report way, we could record the app_path directly. for example,

in

self.testsuite.add_unity_test_cases(log)

it could be self.testsuite.add_unity_test_cases(log, test_case_name=self.test_case_name , which writes the test_case_name to pytest_case_name

multi-dut test cases

we could modify this function instead

def process_raw_report_data(self, raw_data_to_report) -> t.Dict:

to insert the pytest_case_name


by these approaches, the data we recorded in the objects is correct. we don't have to generate the wrong one first, then write a function to replace the wrong one into correct ones.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this suggestion isn't viable. For example, self.testsuite.add_unity_test_cases is executed only within the expect_unity_test_output context. However, there are numerous scenarios where users call expect_exact. Additionally, I tested it on the provided tests in this PR, and in both cases, the proposed solution either fails to work or requires significantly more changes compared to the current implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this work in #338, please take a look. I'll close this PR.

pytest-embedded/pytest_embedded/plugin.py Outdated Show resolved Hide resolved
@alekseiapa alekseiapa force-pushed the fix/add-app-path-to-junit-report-suite branch from 381db08 to 4191a35 Compare January 24, 2025 02:27
@hfudev hfudev closed this Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Record app_path in Junit Reports (RDT-1098)
3 participants