Skip to content

Instantly share code, notes, and snippets.

@mkorpela
Created November 9, 2012 11:55
Show Gist options
  • Save mkorpela/4045349 to your computer and use it in GitHub Desktop.
Save mkorpela/4045349 to your computer and use it in GitHub Desktop.
Log failure information to command line
# Copyright 2008-2012 Nokia Siemens Networks Oyj
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from robot.result import ExecutionResult
from robot.result.visitor import ResultVisitor
class Feiluret(ResultVisitor):
def __init__(self):
self.feilureita = 0
self._feiled_keywords = []
def start_test(self, test):
self._feiled_keywords = []
def end_test(self, test):
if not test.passed:
self.feilureita += 1
print self._format_feilure(test)
def end_keyword(self, keyword):
if not keyword.passed:
self._feiled_keywords += [keyword]
def _format_feilure(self, test):
return 'Test "%s" failed in keyword(s): %s' % (test.name, ' -> '.join(k.name for k in reversed(self._feiled_keywords)))
if __name__ == '__main__':
e = ExecutionResult('output.xml')
f = Feiluret()
e.visit(f)
print 'Total failed tests: ', f.feilureita
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment