-
Notifications
You must be signed in to change notification settings - Fork 66
Added test suite attributes #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,8 +73,8 @@ def test_single_suite_no_test_cases(self): | |
|
||
(ts, tcs) = serialize_and_read( | ||
TestSuite( | ||
'test', | ||
[], | ||
name='test', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you can see after you changed the constructors signature you broke the tests already. That could be someones code :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, I just add attributes explicitly in constructor signature. I think I don't break anyone's code :___( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Off course not. My comment was about this: imagine you have a function and a test:
If you change the signature of
So the test now works but still there are guys out there whose code broke :) So the failing test was a red flag here. If you did not - then it's fine. |
||
test_cases=[], | ||
hostname='localhost', | ||
id=1, | ||
properties=properties, | ||
|
@@ -100,8 +100,8 @@ def test_single_suite_no_test_cases_utf8(self): | |
timestamp = 1398382805 | ||
|
||
test_suite = TestSuite( | ||
'äöü', | ||
[], | ||
name='äöü', | ||
test_cases=[], | ||
hostname='löcalhost', | ||
id='äöü', | ||
properties=properties, | ||
|
@@ -131,8 +131,8 @@ def test_single_suite_no_test_cases_unicode(self): | |
|
||
(ts, tcs) = serialize_and_read( | ||
TestSuite( | ||
decode('äöü', 'utf-8'), | ||
[], | ||
name=decode('äöü', 'utf-8'), | ||
test_cases=[], | ||
hostname=decode('löcalhost', 'utf-8'), | ||
id=decode('äöü', 'utf-8'), | ||
properties=properties, | ||
|
@@ -198,9 +198,8 @@ def test_multiple_suites_to_string(self): | |
verify_test_case(self, suites[1][1][0], {'name': 'Test2'}) | ||
|
||
def test_attribute_time(self): | ||
tss = [TestSuite('suite1', | ||
[TestCase('Test1', 'some.class.name', 123.345), | ||
TestCase('Test2', 'some2.class.name', 123.345)]), | ||
tss = [TestSuite('suite1', [TestCase(name='Test1', classname='some.class.name', elapsed_sec=123.345), | ||
TestCase(name='Test2', classname='some2.class.name', elapsed_sec=123.345)]), | ||
TestSuite('suite2', [TestCase('Test2')])] | ||
suites = serialize_and_read(tss) | ||
|
||
|
@@ -212,21 +211,60 @@ def test_attribute_time(self): | |
# testcase | ||
self.assertEqual('0', suites[1][0].attributes['time'].value) | ||
|
||
def test_attribute_disable(self): | ||
tc = TestCase('Disabled-Test') | ||
tc.is_enabled = False | ||
tss = [TestSuite('suite1', [tc])] | ||
suites = serialize_and_read(tss) | ||
|
||
self.assertEqual('1', suites[0][0].attributes['disabled'].value) | ||
|
||
def test_stderr(self): | ||
suites = serialize_and_read( | ||
TestSuite(name='test', stderr='I am stderr!', | ||
test_cases=[TestCase(name='Test1')]))[0] | ||
self.assertEqual('I am stderr!', | ||
suites[0].getElementsByTagName('system-err')[0].firstChild.data) | ||
|
||
def test_stdout_stderr(self): | ||
suites = serialize_and_read( | ||
TestSuite(name='test', stdout='I am stdout!', | ||
stderr='I am stderr!', | ||
test_cases=[TestCase(name='Test1')]))[0] | ||
self.assertEqual('I am stderr!', | ||
suites[0].getElementsByTagName('system-err')[0].firstChild.data) | ||
self.assertEqual('I am stdout!', | ||
suites[0].getElementsByTagName('system-out')[0].firstChild.data) | ||
|
||
def test_no_assertions(self): | ||
suites = serialize_and_read( | ||
TestSuite(name='test', | ||
test_cases=[TestCase(name='Test1')]))[0] | ||
self.assertFalse(suites[0].getElementsByTagName('testcase')[0].hasAttribute('assertions')) | ||
|
||
def test_assertions(self): | ||
suites = serialize_and_read( | ||
TestSuite(name='test', | ||
test_cases=[TestCase(name='Test1', | ||
assertions=5)]))[0] | ||
self.assertEquals('5', | ||
suites[0].getElementsByTagName('testcase')[0].attributes['assertions'].value) | ||
|
||
# @todo: add more tests for the other attributes and properties | ||
|
||
def test_to_xml_string(self): | ||
test_suites = [TestSuite('suite1', [TestCase('Test1')]), | ||
TestSuite('suite2', [TestCase('Test2')])] | ||
test_suites = [TestSuite(name='suite1', test_cases=[TestCase(name='Test1')]), | ||
TestSuite(name='suite2', test_cases=[TestCase(name='Test2')])] | ||
xml_string = TestSuite.to_xml_string(test_suites) | ||
if PY2: | ||
self.assertTrue(isinstance(xml_string, unicode)) | ||
expected_xml_string = textwrap.dedent(""" | ||
<?xml version="1.0" ?> | ||
<testsuites errors="0" failures="0" tests="2" time="0.0"> | ||
\t<testsuite errors="0" failures="0" name="suite1" skipped="0" tests="1" time="0"> | ||
<testsuites disabled="0" errors="0" failures="0" tests="2" time="0.0"> | ||
\t<testsuite disabled="0" errors="0" failures="0" name="suite1" skipped="0" tests="1" time="0"> | ||
\t\t<testcase name="Test1"/> | ||
\t</testsuite> | ||
\t<testsuite errors="0" failures="0" name="suite2" skipped="0" tests="1" time="0"> | ||
\t<testsuite disabled="0" errors="0" failures="0" name="suite2" skipped="0" tests="1" time="0"> | ||
\t\t<testcase name="Test2"/> | ||
\t</testsuite> | ||
</testsuites> | ||
|
@@ -298,6 +336,12 @@ def test_init_stdout_stderr(self): | |
'time': ("%f" % 123.345)}, | ||
stdout='I am stdout!', stderr='I am stderr!') | ||
|
||
def test_init_disable(self): | ||
tc = TestCase('Disabled-Test') | ||
tc.is_enabled = False | ||
(ts, tcs) = serialize_and_read(TestSuite('test', [tc]))[0] | ||
verify_test_case(self, tcs[0], {'name': 'Disabled-Test'}) | ||
|
||
def test_init_failure_message(self): | ||
tc = TestCase('Failure-Message') | ||
tc.add_failure_info("failure message") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you have also changed the signtature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed back the signature as it was in #38 before my #41 (where I broke the signature)
def __init__(self, name, classname=None, elapsed_sec=None, stdout=None, stderr=None):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sorry.