From bff19ac90b706b20976b39ecc140ebe8d9edc7e0 Mon Sep 17 00:00:00 2001 From: Dong Ma Date: Wed, 14 Sep 2016 12:46:16 +0800 Subject: [PATCH] Update cucumber-testresult plugin - update cucumber-testresult plugin to use convert xml - add plugin="cucumber-testresult-plugin" attribute - add new parameter 'ignore-bad-steps' support - update test cases Change-Id: I8ef353fea030dc0aab0cf9f006fdc84c72834ee7 --- jenkins_jobs/modules/publishers.py | 26 +++++++++++++------ ...t.xml => cucumber-testresult-complete.xml} | 3 ++- .../cucumber-testresult-complete.yaml | 4 +++ .../fixtures/cucumber-testresult-minimal.xml | 9 +++++++ ....yaml => cucumber-testresult-minimal.yaml} | 0 5 files changed, 33 insertions(+), 9 deletions(-) rename tests/publishers/fixtures/{cucumber_testresult.xml => cucumber-testresult-complete.xml} (74%) create mode 100644 tests/publishers/fixtures/cucumber-testresult-complete.yaml create mode 100644 tests/publishers/fixtures/cucumber-testresult-minimal.xml rename tests/publishers/fixtures/{cucumber_testresult.yaml => cucumber-testresult-minimal.yaml} (100%) diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index fb91b9fe6..21654b99f 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -1198,23 +1198,33 @@ def cucumber_testresult(registry, xml_parent, data): Requires the Jenkins :jenkins-wiki:`cucumber testresult `. - :arg str results: results filename (required) + :arg str results: Results filename (required) + :arg bool ignore-bad-steps: Ignore not existed step results (default false) - Example: + Minimal example: .. literalinclude:: - /../../tests/publishers/fixtures/cucumber_testresult.yaml - :language: yaml + /../../tests/publishers/fixtures/cucumber-testresult-minimal.yaml + :language: yaml + Full Example: + + .. literalinclude:: + /../../tests/publishers/fixtures/cucumber-testresult-complete.yaml + :language: yaml """ cucumber_result = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.cucumber.' 'jsontestsupport.' 'CucumberTestResultArchiver') - filepath = data.get('results', None) - if filepath is None: - raise MissingAttributeError('results') - XML.SubElement(cucumber_result, 'testResults').text = str(filepath) + cucumber_result.set('plugin', 'cucumber-testresult-plugin') + + mappings = [ + ('results', 'testResults', None), + ('ignore-bad-steps', 'ignoreBadSteps', False) + ] + helpers.convert_mapping_to_xml( + cucumber_result, data, mappings, fail_required=True) def xunit(registry, xml_parent, data): diff --git a/tests/publishers/fixtures/cucumber_testresult.xml b/tests/publishers/fixtures/cucumber-testresult-complete.xml similarity index 74% rename from tests/publishers/fixtures/cucumber_testresult.xml rename to tests/publishers/fixtures/cucumber-testresult-complete.xml index 5d2331fb9..6f44beaa1 100644 --- a/tests/publishers/fixtures/cucumber_testresult.xml +++ b/tests/publishers/fixtures/cucumber-testresult-complete.xml @@ -1,8 +1,9 @@ - + nosetests.xml + true diff --git a/tests/publishers/fixtures/cucumber-testresult-complete.yaml b/tests/publishers/fixtures/cucumber-testresult-complete.yaml new file mode 100644 index 000000000..6a00d02b1 --- /dev/null +++ b/tests/publishers/fixtures/cucumber-testresult-complete.yaml @@ -0,0 +1,4 @@ +publishers: +- cucumber-testresult: + results: nosetests.xml + ignore-bad-steps: true diff --git a/tests/publishers/fixtures/cucumber-testresult-minimal.xml b/tests/publishers/fixtures/cucumber-testresult-minimal.xml new file mode 100644 index 000000000..8992e977d --- /dev/null +++ b/tests/publishers/fixtures/cucumber-testresult-minimal.xml @@ -0,0 +1,9 @@ + + + + + nosetests.xml + false + + + diff --git a/tests/publishers/fixtures/cucumber_testresult.yaml b/tests/publishers/fixtures/cucumber-testresult-minimal.yaml similarity index 100% rename from tests/publishers/fixtures/cucumber_testresult.yaml rename to tests/publishers/fixtures/cucumber-testresult-minimal.yaml