Commit fefb3160 by Gabriel Falcão

traceback on failed, with colorless output

parent 003a47ee
......@@ -551,12 +551,20 @@ class TotalResult(object):
self.feature_results = feature_results
self.scenario_results = []
self.steps_passed = 0
self.steps_failed = 0
self.steps_skipped = 0
self.steps_undefined= 0
self.proposed_definitions = []
self.steps = 0
for feature_result in self.feature_results:
for scenario_result in feature_result.scenario_results:
self.scenario_results.append(scenario_result)
self.steps_passed += len(scenario_result.steps_passed)
self.steps_failed += len(scenario_result.steps_failed)
self.steps_skipped += len(scenario_result.steps_skipped)
self.steps_undefined += len(scenario_result.steps_undefined)
self.steps += scenario_result.total_steps
self.proposed_definitions.extend(scenario_result.steps_undefined)
@property
def features_ran(self):
......
......@@ -14,6 +14,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/>.
import re
import os
import sys
from lettuce.terrain import after
......@@ -74,14 +75,33 @@ def print_end(total):
)
)
steps_details = []
for kind in ("failed","skipped", "undefined"):
attr = 'steps_%s' % kind
stotal = getattr(total, attr)
if stotal:
steps_details.append(
"%d %s" % (stotal, kind)
)
steps_details.append("%d passed" % total.steps_passed)
word = total.steps > 1 and "steps" or "step"
sys.stdout.write("%d %s (%d passed)\n" % (
sys.stdout.write("%d %s (%s)\n" % (
total.steps,
word,
total.steps_passed
", ".join(steps_details)
)
)
if total.proposed_definitions:
sys.stdout.write("\nYou can implement step definitions for undefined steps with these snippets:\n\n")
sys.stdout.write("from lettuce import step\n\n")
for step in total.proposed_definitions:
method_name = "_".join(re.findall("\w+", step.sentence)).lower()
sys.stdout.write("@step(r'%s')\n" % re.escape(step.sentence).replace(r'\ ', ' '))
sys.stdout.write("def %s(step):\n" % method_name)
sys.stdout.write(" pass\n")
def print_no_features_found(where):
where = os.path.relpath(where)
if not where.startswith(os.sep):
......
......@@ -402,9 +402,9 @@ def test_output_with_failed_colorless_with_table():
"\033[A And this one will be skipped # tests/functional/output_features/failed_table/failed_table_steps.py:28\n"
" And this one does not even has definition # tests/functional/output_features/failed_table/failed_table.feature:12 (undefined)\n"
"\n"
"1 feature (1 failed)\n"
"1 scenario (1 failed)\n"
"4 steps (1 failed, 1 skipped, 1 undefined, 1 passed)\n"
"1 feature (0 passed)\n"
"1 scenario (0 passed)\n"
"5 steps (1 failed, 2 skipped, 1 undefined, 1 passed)\n"
"\n"
"You can implement step definitions for undefined steps with these snippets:\n"
"\n"
......
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