4.1. qa_analytics_insights package
4.1.1. Submodules
4.1.2. qa_analytics_insights.cli module
Copyright (c) 2023, Aydin Abdi.
Command line interface for the qa-analytics-insights package.
- class qa_analytics_insights.cli.ArgsParser[source]
Bases:
objectClass for handling command line arguments.
- property args: Namespace
Return the parsed arguments.
- Returns:
Namespace object.
- property parser: ArgumentParser
Return the parser object.
- Returns:
ArgumentParser object.
4.1.3. qa_analytics_insights.data_classes module
Copyright (c) 2023, Aydin Abdi.
This file contains the data classes used in the qa-analytics-insights package.
- class qa_analytics_insights.data_classes.TestCase(name: str, test_module: str | None = None, test_class: str | None = None, execution_time: float = 0.0, result: str = 'passed', timestamp: str | None = None, failure_reason: str | None = None, error_reason: str | None = None, skipped_reason: str | None = None, system_out: str | None = None)[source]
Bases:
objectRepresents a test case.
- Parameters:
name – Name of the test case.
test_module – Name of the test module.
test_class – Name of the test class.
execution_time – Execution time of the test case.
result – Result of the test case.
timestamp – Timestamp of the test case.
failure_reason – Failure reason of the test case.
skipped_reason – Skipped reason of the test case.
system_out – System out of the test case.
- error_reason: str | None = None
- execution_time: float = 0.0
- failure_reason: str | None = None
- name: str
- result: str = 'passed'
- skipped_reason: str | None = None
- system_out: str | None = None
- test_class: str | None = None
- test_module: str | None = None
- timestamp: str | None = None
- class qa_analytics_insights.data_classes.TestClass(name: str, test_cases: ~typing.List[~qa_analytics_insights.data_classes.TestCase] = <factory>)[source]
Bases:
objectRepresents a test class.
- Parameters:
name – Name of the test class.
test_cases – List of test cases in the test class.
passed – Number of passed tests in the test class.
failed – Number of failed tests in the test class.
skipped – Number of skipped tests in the test class.
errors – Number of errors in the test class.
execution_time – Execution time of the test class.
failed_test_cases – List of failed test cases in the test class.
skipped_test_cases – List of skipped test cases in the test class.
error_test_cases – List of error test cases in the test class.
- errors: int = 0
- execution_time: float = 0.0
- failed: int = 0
- name: str
- passed: int = 0
- skipped: int = 0
- class qa_analytics_insights.data_classes.TestSuite(name: str | None = None, tests: int = 0, errors: int = 0, failures: int = 0, skipped: int = 0, execution_time: float = 0.0, timestamp: str | None = None, test_classes: ~typing.List[~qa_analytics_insights.data_classes.TestClass] = <factory>, test_cases: ~typing.List[~qa_analytics_insights.data_classes.TestCase] = <factory>)[source]
Bases:
objectRepresents a test suite.
- Parameters:
name – Name of the test suite.
tests – Total number of tests.
errors – Total number of errors.
failures – Total number of failures.
skipped – Total number of skipped tests.
execution_time – Total execution time of the test suite.
timestamp – Timestamp of the test suite.
test_classes – List of test classes in the test suite.
test_cases – List of ungrouped test cases in the test suite.
passed – Number of passed tests in the test suite.
- errors: int = 0
- execution_time: float = 0.0
- failures: int = 0
- name: str | None = None
- passed: int = 0
- skipped: int = 0
- tests: int = 0
- timestamp: str | None = None
4.1.4. qa_analytics_insights.log module
Copyright (c) 2023, Aydin Abdi.
This module is responsible for logging.
4.1.5. qa_analytics_insights.parser module
Copyright (c) 2023, Aydin Abdi.
This module is responsible for parsing test cases from XML tags.
- class qa_analytics_insights.parser.ParserTestCase(test_case: Element)[source]
Bases:
objectResponsible for parsing TestCase objects from XML tags.
- find_tag_attribute(tag: str, attrib: str | None = None) str | None[source]
Find the tag for test case element and return the attribute or text.
- Parameters:
tag – Tag to parse.
attrib – Attribute to parse. If None, the tag text is returned.
- Returns:
Find the tag and return the attribute or text.
- get_failure_reason(tag: str = 'failure') str | None[source]
Parse the failure reason from a failure tag.
- Parameters:
tag – XML element representing a failure tag. Defaults to “failure”.
- Returns:
Failure reason.
- get_skipped_reason(tag: str = 'skipped') str | None[source]
Parse the skipped reason from a skipped tag.
- Parameters:
tag – XML element representing a skipped tag. Defaults to “skipped”.
- Returns:
Skipped reason.
- get_system_out(tag: str = 'system-out') str | None[source]
Parse the system out from a system-out tag.
- Parameters:
tag – Tag to parse.
- Returns:
System out or None if no system out is found.
- get_testcase_result() str[source]
Parses the test case result from the test case tag.
- Returns:
Test case result.
4.1.6. qa_analytics_insights.patch_fetcher module
Copyright (c) 2023, Aydin Abdi.
This module is responsible for fetching paths from the given initial path.
4.1.7. qa_analytics_insights.result_analyzer module
Copyright (c) 2023, Aydin Abdi.
ResultAnalyzer implements the logic for analyzing the test results with different metrics which can be used to visualize the results.
- class qa_analytics_insights.result_analyzer.ResultAnalyzer(path: str, num_threads: int = 10)[source]
Bases:
objectAnalyzes the test results with several metrics.
Example
slowest_test_classes
slowest_test_cases
failed_test_cases with failure_reason
skipped_test_cases with skipped_reason
execution times by test class in descending order
- get_execution_times_by_test_class_in_descending_order() List[TestClass][source]
Return the test classes sorted by execution time in descending order.
- Returns:
List of TestClass objects.
- get_slowest_test_classes(num_test_classes: int = 10) List[TestClass][source]
Return the slowest test classes.
- Parameters:
num_test_classes – Number of test classes to return.
- Returns:
List of TestClass objects.
4.1.8. qa_analytics_insights.result_visualizer module
Copyright (c) 2023, Aydin Abdi.
This module is responsible for visualizing the results of the parsed TestClass objects.
- class qa_analytics_insights.result_visualizer.ParallelResultVisualizer(test_suites: List[TestSuite] | None = None)[source]
Bases:
ResultVisualizerClass to visualize the results of the parsed TestClass objects in parallel.
- class qa_analytics_insights.result_visualizer.ResultVisualizer(test_suites: List[TestSuite] | None = None)[source]
Bases:
objectClass for visualizing test results.
- build_subplots_failed_table() str | None[source]
Plot a table of failed test cases.
- Returns:
The base64 encoded string representation of the figure.
- build_subplots_pie_chart_test_classes_results() str | None[source]
Plot the results of the parsed TestClass objects.
- Returns:
The base64 encoded string representation of the figure.
- build_subplots_skipped_table() str | None[source]
Plot a table of skipped test cases.
- Returns:
The base64 encoded string representation of the figure.
- build_subplots_test_suites_summary_table() str | None[source]
Plot a table of test suites summary.
- Returns:
The base64 encoded string representation of the figure.
- build_subplots_top_slowest_test_classes(slowest_test_classes: List[TestClass]) str | None[source]
Plot a pie bar chart of the top slowest test classes.
- Parameters:
slowest_test_classes – List of the slowest test classes.
- Returns:
The base64 encoded string representation of the figure.
- static figure_to_base64(figure: Figure) str[source]
Convert a Matplotlib figure to a base64 string.
- Parameters:
figure – The figure to convert.
- Returns:
The base64 encoded string representation of the figure.
- static generate_html_report_to_file(output: str, pie_charts: str | None = None, failed_table: str | None = None, skipped_table: str | None = None, summary_table: str | None = None, slowest_classes: str | None = None) None[source]
Generate an HTML report of the test results.
- Parameters:
pie_charts – Base64 string representing the pie charts.
failed_table – Base64 string representing the failed test cases table.
skipped_table – Base64 string representing the skipped test cases table.
summary_table – Base64 string representing the test suites summary table.
slowest_classes – Base64 string representing the top slowest test classes.
output – Output file name.
- plot_failed_test_cases_table() Figure | None[source]
Plot a table of failed/error test cases.
- Returns:
The figure for failed/error test cases table.
- plot_pie_charts_test_classes() Figure | None[source]
Plot pie charts for each test class.
- Returns:
Figure containing the pie charts.
- plot_skipped_test_cases_table() Figure | None[source]
Plot a table of skipped test cases.
- Returns:
The figure for skipped test cases table.
- plot_test_suites_summary_table() Figure | None[source]
Plot a table of test suites summary.
- Returns:
The figure for test suites summary table.
- plot_top_slowest_test_classes_pie_bar_chart(slowest_test_classes: List[TestClass] | None = None) Figure | None[source]
Plot a pie bar chart of the top slowest test classes.
- Parameters:
slowest_test_classes – List of the slowest test classes.
- Returns:
The figure for the top slowest test classes pie bar chart.
- run(output: str = 'test_results_visualization', pie_charts: Figure | None = None, failed_table: Figure | None = None, skipped_table: Figure | None = None, summary_table: Figure | None = None, slowest_classes: List[TestClass] | None = None) None[source]
Main execution method.
- Parameters:
output – Output file name.
pie_charts – Figure containing the pie charts.
failed_table – Figure containing the failed test cases table.
skipped_table – Figure containing the skipped test cases table.
slowest_classes – List of the slowest test classes.
summary_table – Figure containing the test suites summary table.
4.1.9. qa_analytics_insights.xml_filter module
Copyright (c) 2023, Aydin Abdi.
This module filters XML files from the given path queue.
4.1.10. qa_analytics_insights.xml_loader module
Copyright (c) 2023, Aydin Abdi.
This module is responsible for loading XML files.
4.1.11. qa_analytics_insights.xml_parser module
Copyright (c) 2023, Aydin Abdi.
This module is responsible for parsing XML files into TestSuite objects.
- class qa_analytics_insights.xml_parser.XMLParser(xml_tag_finder: XMLTagFinder)[source]
Bases:
objectResponsible for parsing XML files into TestClass and TestCase objects.
4.1.12. qa_analytics_insights.xml_processor module
Copyright (c) 2023, Aydin Abdi.
This module processes files in the given path in parallel and puts the xml files in a queue for further processing.
4.1.13. qa_analytics_insights.xml_tag_finder module
Copyright (c) 2023, Aydin Abdi.
This module is responsible for finding XML tags in XML files.
- class qa_analytics_insights.xml_tag_finder.XMLTagFinder(xml_loader: XMLLoader)[source]
Bases:
objectResponsible for finding XML tags in XML files.
- property suite: Element
Returns the suite element.
This method returns the testsuite element if it exists. If the testsuite element does not exist, it returns the root element.
- Returns:
Suite element.
- property test_cases: List[Element]
Returns all the testcase tags in the XML file.
- Returns:
List of testcase tags.
4.1.14. Module contents
Copyright (c) 2023, Aydin Abdi.
This module is analyze and extracts the data from test results and can visualize the data in different ways.