mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-09-22 15:04:33 -07:00
Implement test case prefix to filter test cases (#40174)
* Implement test case prefix to filter test cases * Cut line to not exceed 160 chars * Replace tabs with spaces * Add version_added field * Include changelog file
This commit is contained in:
parent
8d01e26d18
commit
e2f85b3f6c
2 changed files with 16 additions and 1 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- junit callback plug-in - introduce a new option to consider a task only as test case if it has this value as prefix.
|
|
@ -65,6 +65,13 @@ DOCUMENTATION = '''
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
env:
|
env:
|
||||||
- name: JUNIT_HIDE_TASK_ARGUMENTS
|
- name: JUNIT_HIDE_TASK_ARGUMENTS
|
||||||
|
test_case_prefix:
|
||||||
|
name: Prefix to find actual test cases
|
||||||
|
default: <empty>
|
||||||
|
description: Consider a task only as test case if it has this value as prefix. Additionaly failing tasks are recorded as failed test cases.
|
||||||
|
version_added: "2.8"
|
||||||
|
env:
|
||||||
|
- name: JUNIT_TEST_CASE_PREFIX
|
||||||
requirements:
|
requirements:
|
||||||
- whitelist in configuration
|
- whitelist in configuration
|
||||||
- junit_xml (python lib)
|
- junit_xml (python lib)
|
||||||
|
@ -122,6 +129,9 @@ class CallbackModule(CallbackBase):
|
||||||
Default: True
|
Default: True
|
||||||
JUNIT_HIDE_TASK_ARGUMENTS (optional): Hide the arguments for a task
|
JUNIT_HIDE_TASK_ARGUMENTS (optional): Hide the arguments for a task
|
||||||
Default: False
|
Default: False
|
||||||
|
JUNIT_TEST_CASE_PREFIX (optional): Consider a task only as test case if it has this value as prefix. Additionaly failing tasks are recorded as failed
|
||||||
|
test cases.
|
||||||
|
Default: <empty>
|
||||||
|
|
||||||
Requires:
|
Requires:
|
||||||
junit_xml
|
junit_xml
|
||||||
|
@ -143,6 +153,7 @@ class CallbackModule(CallbackBase):
|
||||||
self._fail_on_ignore = os.getenv('JUNIT_FAIL_ON_IGNORE', 'False').lower()
|
self._fail_on_ignore = os.getenv('JUNIT_FAIL_ON_IGNORE', 'False').lower()
|
||||||
self._include_setup_tasks_in_report = os.getenv('JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT', 'True').lower()
|
self._include_setup_tasks_in_report = os.getenv('JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT', 'True').lower()
|
||||||
self._hide_task_arguments = os.getenv('JUNIT_HIDE_TASK_ARGUMENTS', 'False').lower()
|
self._hide_task_arguments = os.getenv('JUNIT_HIDE_TASK_ARGUMENTS', 'False').lower()
|
||||||
|
self._test_case_prefix = os.getenv('JUNIT_TEST_CASE_PREFIX', '')
|
||||||
self._playbook_path = None
|
self._playbook_path = None
|
||||||
self._playbook_name = None
|
self._playbook_name = None
|
||||||
self._play_name = None
|
self._play_name = None
|
||||||
|
@ -211,7 +222,8 @@ class CallbackModule(CallbackBase):
|
||||||
elif status == 'ok':
|
elif status == 'ok':
|
||||||
status = 'failed'
|
status = 'failed'
|
||||||
|
|
||||||
task_data.add_host(HostData(host_uuid, host_name, status, result))
|
if task_data.name.startswith(self._test_case_prefix) or status == 'failed':
|
||||||
|
task_data.add_host(HostData(host_uuid, host_name, status, result))
|
||||||
|
|
||||||
def _build_test_case(self, task_data, host_data):
|
def _build_test_case(self, task_data, host_data):
|
||||||
""" build a TestCase from the given TaskData and HostData """
|
""" build a TestCase from the given TaskData and HostData """
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue