Mercurial > bitten > bitten-test
changeset 777:ab6fdaaf34f6
Handle py.test skipped statuses correctly. Fixes #564.
author | hodgestar |
---|---|
date | Mon, 26 Apr 2010 23:15:21 +0000 |
parents | 025b3e889321 |
children | d29499a4450c |
files | bitten/build/javatools.py bitten/build/tests/javatools.py |
diffstat | 2 files changed, 38 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/bitten/build/javatools.py +++ b/bitten/build/javatools.py @@ -149,9 +149,16 @@ result = list(testcase.children()) if result: - test.attr['status'] = result[0].name + junit_status = result[0].name test.append(xmlio.Element('traceback')[_fix_traceback(result)]) - failed += 1 + if junit_status == 'skipped': + test.attr['status'] = 'ignore' + elif junit_status == 'error': + test.attr['status'] = 'error' + failed += 1 + else: + test.attr['status'] = 'failure' + failed += 1 else: test.attr['status'] = 'success'
--- a/bitten/build/tests/javatools.py +++ b/bitten/build/tests/javatools.py @@ -16,7 +16,7 @@ import unittest from bitten.build import javatools -from bitten.recipe import Context +from bitten.recipe import Context, Recipe class CoberturaTestCase(unittest.TestCase): xml_template="""<?xml version="1.0"?> @@ -182,6 +182,34 @@ self.assertEqual(1, len(trace.children)) self.assertEqual('request = <FuncargRequest for <Function...', trace.children[0]) + type, category, generator, xml = self.ctxt.output.pop() + self.assertEqual(Recipe.ERROR, type) + + self.assertEqual(0, len(self.ctxt.output)) + + def test_skipped_tests(self): + """Check that skipped tests (here: xfail in py.test) are not considered an error""" + body = '<testcase classname="_test.test_event" name="test_simple" time="0.06">' \ + + '<skipped/></testcase>' + filename = self._xml_file(body, skips=1) + javatools.junit(self.ctxt, file_=filename) + type, category, generator, xml = self.ctxt.output.pop() + self.assertEqual('report', type) + self.assertEqual('test', category) + self.assertEqual(1, len(xml.children)) + + elem = xml.children[0] + self.assertEqual('test', elem.name) + self.assertEqual('test_simple', elem.attr['name']) + self.assertEqual('ignore', elem.attr['status']) + self.assertEqual(1, len(elem.children)) + + trace = elem.children[0] + self.assertEqual('traceback', trace.name) + self.assertEqual(0, len(trace.children)) + + self.assertEqual(0, len(self.ctxt.output)) + def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(CoberturaTestCase, 'test'))