Commit 79e52bf4 by Petar Shomov

xunit plugin does not throw exception when missing step definition

parent b25b4841
......@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from datetime import datetime
from datetime import datetime, timedelta
from lettuce.terrain import after
from lettuce.terrain import before
from xml.dom import minidom
......@@ -56,7 +56,10 @@ def enable(filename=None):
tc = doc.createElement("testcase")
tc.setAttribute("classname", classname.encode('utf-8'))
tc.setAttribute("name", step.sentence.encode('utf-8'))
tc.setAttribute("time", str(total_seconds((datetime.now() - step.started))))
try:
tc.setAttribute("time", str(total_seconds((datetime.now() - step.started))))
except AttributeError:
tc.setAttribute("time", str(total_seconds(timedelta(seconds=0))))
if not step.ran:
skip=doc.createElement("skipped")
......
Feature: Missing steps do not cause the xunit plugin to throw
Scenario: It should pass
Given my sdfsdf sdfsdf sdfs df sdfsdf
......@@ -120,4 +120,17 @@ def test_xunit_output_with_unicode_characters_in_error_messages():
assert_equals(1, len(called), "Function not called")
xunit_output.wrt_output = old
@with_setup(prepare_stdout, registry.clear)
def test_xunit_does_not_throw_exception_when_missing_step_definition():
def dummy_write(filename, content):
pass
old = xunit_output.wrt_output
xunit_output.wrt_output = dummy_write
runner = Runner(feature_name('missing_steps'), enable_xunit=True,
xunit_filename="mising_steps.xml")
runner.run()
xunit_output.wrt_output = old
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment