Skip to content

Commit

Permalink
enhanced xunit feature to verify contents of xunit report
Browse files Browse the repository at this point in the history
covers pass, fail and undefined cases
  • Loading branch information
dexterous committed Sep 21, 2011
1 parent 94251d0 commit d5845ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions features/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,21 @@ def check_outcome_with_xunit(exp_status, xunit_file):

from xml.dom.minidom import parse
scc.xunit_report = parse(xunit_file)

status_tests = {
'passed': lambda t: not t.hasChildNodes(),
'failed': lambda t: t.hasChildNodes() and
t.firstChild.hasAttributes() and
not t.firstChild.getAttribute('type').startswith('freshen'),
'undefined': lambda t: t.hasChildNodes() and
t.firstChild.hasAttributes() and
t.firstChild.getAttribute('type') == 'freshen.stepregistry.UndefinedStepImpl'
}

@Then("^it should report (\w+) from (\w+) as (passed|failed|undefined)$")
def check_xunit_report(scenario, feature, exp_status):
testcase = filter( lambda t: t.getAttribute('classname') == 'freshen.noseplugin.' + feature and
t.getAttribute('name') == scenario,
scc.xunit_report.getElementsByTagName('testcase'))[0]

assert_true(status_tests[exp_status](testcase))
8 changes: 4 additions & 4 deletions features/xunit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Feature: XUnit output
In order to report feature/scenario execution to programs such as CI servers
and reporting tools, they should be provided better output in XUnit format

Scenario: Run all scenarios in sample feature
Scenario: Run all scenarios in sample feature and ensure xunit report is generated with appropriate contents
When I run nose --with-xunit --xunit-file=/tmp/nosetests.xml examples/self_test/features/sample.feature
Then it should fail with xunit file /tmp/nosetests.xml
#And it should report Passing from Sample as passed
#And it should report Failin from Sample as failed
#And it should report Missing from Sample as undefined
And it should report Passing from Sample as passed
And it should report Failing from Sample as failed
And it should report Missing from Sample as undefined

0 comments on commit d5845ab

Please sign in to comment.