Update TestNG plugin
- Add support for new options - Add minimal and full tests - Update to use convert_mapping_to_xml - Update doc option to have default values - Add plugin="testng-plugin" attribute Change-Id: I8dcf3ad8e0aeb753668f8bf07c40fd55e11b4dc0 Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
parent
1c22158672
commit
cad8d5d070
@ -4282,26 +4282,65 @@ def testng(parser, xml_parent, data):
|
|||||||
Requires the Jenkins :jenkins-wiki:`TestNG Results Plugin <testng-plugin>`.
|
Requires the Jenkins :jenkins-wiki:`TestNG Results Plugin <testng-plugin>`.
|
||||||
|
|
||||||
:arg str pattern: filename pattern to locate the TestNG XML report files
|
:arg str pattern: filename pattern to locate the TestNG XML report files
|
||||||
|
(required)
|
||||||
:arg bool escape-test-description: escapes the description string
|
:arg bool escape-test-description: escapes the description string
|
||||||
associated with the test method while displaying test method details
|
associated with the test method while displaying test method details
|
||||||
(default true)
|
(default true)
|
||||||
:arg bool escape-exception-msg: escapes the test method's exception
|
:arg bool escape-exception-msg: escapes the test method's exception
|
||||||
messages. (default true)
|
messages. (default true)
|
||||||
|
:arg bool fail-on-failed-test-config: Allows for a distinction between
|
||||||
|
failing tests and failing configuration methods (>=1.10) (default
|
||||||
|
false)
|
||||||
|
:arg bool show-failed-builds: include results from failed builds in the
|
||||||
|
trend graph (>=1.6) (default false)
|
||||||
|
:arg int unstable-skips: Build is marked UNSTABLE if the number/percentage
|
||||||
|
of skipped tests exceeds the specified threshold (>=1.11) (default 100)
|
||||||
|
:arg int unstable-fails: Build is marked UNSTABLE if the number/percentage
|
||||||
|
of failed tests exceeds the specified threshold (>=1.11) (default 0)
|
||||||
|
:arg int failed-skips: Build is marked FAILURE if the number/percentage of
|
||||||
|
skipped tests exceeds the specified threshold (>=1.11) (default 100)
|
||||||
|
:arg int failed-fails: Build is marked FAILURE if the number/percentage of
|
||||||
|
failed tests exceeds the specified threshold (>=1.11) (default 100)
|
||||||
|
:arg str threshold-mode: Interpret threshold as number of tests or
|
||||||
|
percentage of tests (>=1.11) (default percentage)
|
||||||
|
|
||||||
Example:
|
Full Example:
|
||||||
|
|
||||||
.. literalinclude:: /../../tests/publishers/fixtures/testng001.yaml
|
.. literalinclude:: /../../tests/publishers/fixtures/testng-full.yaml
|
||||||
|
:language: yaml
|
||||||
|
|
||||||
|
Minimal Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/publishers/fixtures/testng-minimal.yaml
|
||||||
:language: yaml
|
:language: yaml
|
||||||
"""
|
"""
|
||||||
|
|
||||||
reporter = XML.SubElement(xml_parent, 'hudson.plugins.testng.Publisher')
|
reporter = XML.SubElement(xml_parent, 'hudson.plugins.testng.Publisher')
|
||||||
if not data['pattern']:
|
reporter.set('plugin', 'testng-plugin')
|
||||||
raise JenkinsJobsException("A filename pattern must be specified.")
|
valid_threshold_modes = ['number', 'percentage']
|
||||||
XML.SubElement(reporter, 'reportFilenamePattern').text = data['pattern']
|
threshold_mode = data.get('threshold-mode', 'percentage')
|
||||||
XML.SubElement(reporter, 'escapeTestDescp').text = str(data.get(
|
|
||||||
'escape-test-description', True))
|
mappings = [
|
||||||
XML.SubElement(reporter, 'escapeExceptionMsg').text = str(data.get(
|
('pattern', 'reportFilenamePattern', None),
|
||||||
'escape-exception-msg', True))
|
('escape-test-description', 'escapeTestDescp', True),
|
||||||
|
('escape-exception-msg', 'escapeExceptionMsg', True),
|
||||||
|
('fail-on-failed-test-config', 'failureOnFailedTestConfig', False),
|
||||||
|
('show-failed-builds', 'showFailedBuilds', False),
|
||||||
|
('unstable-skips', 'unstableSkips', 100),
|
||||||
|
('unstable-fails', 'unstableFails', 0),
|
||||||
|
('failed-skips', 'failedSkips', 100),
|
||||||
|
('failed-fails', 'failedFails', 100),
|
||||||
|
]
|
||||||
|
helpers.convert_mapping_to_xml(
|
||||||
|
reporter, data, mappings, fail_required=True)
|
||||||
|
|
||||||
|
if threshold_mode == 'number':
|
||||||
|
XML.SubElement(reporter, 'thresholdMode').text = str(1)
|
||||||
|
elif threshold_mode == 'percentage':
|
||||||
|
XML.SubElement(reporter, 'thresholdMode').text = str(2)
|
||||||
|
else:
|
||||||
|
raise InvalidAttributeError(
|
||||||
|
'threshold-mode', threshold_mode, valid_threshold_modes)
|
||||||
|
|
||||||
|
|
||||||
def artifact_deployer(parser, xml_parent, data):
|
def artifact_deployer(parser, xml_parent, data):
|
||||||
|
17
tests/publishers/fixtures/testng-full.xml
Normal file
17
tests/publishers/fixtures/testng-full.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<hudson.plugins.testng.Publisher plugin="testng-plugin">
|
||||||
|
<reportFilenamePattern>**/testng-results.xml</reportFilenamePattern>
|
||||||
|
<escapeTestDescp>false</escapeTestDescp>
|
||||||
|
<escapeExceptionMsg>false</escapeExceptionMsg>
|
||||||
|
<failureOnFailedTestConfig>true</failureOnFailedTestConfig>
|
||||||
|
<showFailedBuilds>true</showFailedBuilds>
|
||||||
|
<unstableSkips>50</unstableSkips>
|
||||||
|
<unstableFails>25</unstableFails>
|
||||||
|
<failedSkips>75</failedSkips>
|
||||||
|
<failedFails>66</failedFails>
|
||||||
|
<thresholdMode>1</thresholdMode>
|
||||||
|
</hudson.plugins.testng.Publisher>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
12
tests/publishers/fixtures/testng-full.yaml
Normal file
12
tests/publishers/fixtures/testng-full.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
publishers:
|
||||||
|
- testng:
|
||||||
|
pattern: "**/testng-results.xml"
|
||||||
|
escape-test-description: false
|
||||||
|
escape-exception-msg: false
|
||||||
|
fail-on-failed-test-config: true
|
||||||
|
show-failed-builds: true
|
||||||
|
unstable-skips: 50
|
||||||
|
unstable-fails: 25
|
||||||
|
failed-skips: 75
|
||||||
|
failed-fails: 66
|
||||||
|
threshold-mode: number
|
17
tests/publishers/fixtures/testng-minimal.xml
Normal file
17
tests/publishers/fixtures/testng-minimal.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<hudson.plugins.testng.Publisher plugin="testng-plugin">
|
||||||
|
<reportFilenamePattern>**/testng-results.xml</reportFilenamePattern>
|
||||||
|
<escapeTestDescp>true</escapeTestDescp>
|
||||||
|
<escapeExceptionMsg>true</escapeExceptionMsg>
|
||||||
|
<failureOnFailedTestConfig>false</failureOnFailedTestConfig>
|
||||||
|
<showFailedBuilds>false</showFailedBuilds>
|
||||||
|
<unstableSkips>100</unstableSkips>
|
||||||
|
<unstableFails>0</unstableFails>
|
||||||
|
<failedSkips>100</failedSkips>
|
||||||
|
<failedFails>100</failedFails>
|
||||||
|
<thresholdMode>2</thresholdMode>
|
||||||
|
</hudson.plugins.testng.Publisher>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
3
tests/publishers/fixtures/testng-minimal.yaml
Normal file
3
tests/publishers/fixtures/testng-minimal.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
publishers:
|
||||||
|
- testng:
|
||||||
|
pattern: "**/testng-results.xml"
|
@ -1,10 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.testng.Publisher>
|
<hudson.plugins.testng.Publisher plugin="testng-plugin">
|
||||||
<reportFilenamePattern>**/target/surefire-reports/testng-results.xml</reportFilenamePattern>
|
<reportFilenamePattern>**/target/surefire-reports/testng-results.xml</reportFilenamePattern>
|
||||||
<escapeTestDescp>False</escapeTestDescp>
|
<escapeTestDescp>false</escapeTestDescp>
|
||||||
<escapeExceptionMsg>True</escapeExceptionMsg>
|
<escapeExceptionMsg>true</escapeExceptionMsg>
|
||||||
|
<failureOnFailedTestConfig>false</failureOnFailedTestConfig>
|
||||||
|
<showFailedBuilds>false</showFailedBuilds>
|
||||||
|
<unstableSkips>100</unstableSkips>
|
||||||
|
<unstableFails>0</unstableFails>
|
||||||
|
<failedSkips>100</failedSkips>
|
||||||
|
<failedFails>100</failedFails>
|
||||||
|
<thresholdMode>2</thresholdMode>
|
||||||
</hudson.plugins.testng.Publisher>
|
</hudson.plugins.testng.Publisher>
|
||||||
</publishers>
|
</publishers>
|
||||||
</project>
|
</project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user