Skip to content

Commit

Permalink
add: Add QACTL test results to stdout logging #1794
Browse files Browse the repository at this point in the history
  • Loading branch information
jmv74211 committed Aug 27, 2021
1 parent c39e8d1 commit f21aca0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
11 changes: 9 additions & 2 deletions deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ def run(self, ansible_inventory_path):
output=self.qa_ctl_configuration.ansible_output)

self.result = TestResult(html_report_file_path=os.path.join(self.tests_result_path, html_report_file_name),
plain_report_file_path=os.path.join(self.tests_result_path, plain_report_file_name))
plain_report_file_path=os.path.join(self.tests_result_path, plain_report_file_name),
test_name=self.tests_path)

Pytest.LOGGER.debug(f"{self.tests_path} tests of {self.hosts} hosts were saved in {self.tests_result_path}")
Pytest.LOGGER.debug(f"{self.tests_path} tests of {self.hosts} hosts were saved in {self.tests_result_path}")

# Print test result in stdout
if self.qa_ctl_configuration.logging_enable:
Pytest.LOGGER.info(self.result)
else:
print(self.result)
15 changes: 13 additions & 2 deletions deps/wazuh_testing/wazuh_testing/qa_ctl/run_tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ class TestResult:
custom_report_file_path (str, None): Local file path pointing to the custom report
"""

def __init__(self, html_report_file_path=None, plain_report_file_path=None,
custom_report_file_path=None):
def __init__(self, html_report_file_path=None, plain_report_file_path=None, custom_report_file_path=None,
test_name=None):
self.html_report_file_path = html_report_file_path
self.plain_report_file_path = plain_report_file_path
self.custom_report_file_path = custom_report_file_path
self.test_name = test_name

def __str__(self):
result = '\n' * 2

with open(self.plain_report_file_path) as plain_report_file:
result += plain_report_file.read()

result += '\n' * 2

return result

def generate_custom_report(self):
pass

0 comments on commit f21aca0

Please sign in to comment.