From 00225476368fbf3ff9821990bd9b66b4aec54c40 Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Fri, 18 Apr 2014 18:29:25 +0200 Subject: [PATCH] catch exceptions when running the spec blocks, print them and count them --- test/test-android/app/main.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/test-android/app/main.rb b/test/test-android/app/main.rb index 8679374e..a1d6ce4a 100644 --- a/test/test-android/app/main.rb +++ b/test/test-android/app/main.rb @@ -3,6 +3,8 @@ $specs = [] $describe = nil $befores = [] $afters = [] +$specs_total = 0 +$specs_exceptions = 0 $expectations_total = 0 $expectations_failures = 0 @@ -56,9 +58,16 @@ class Object end def it(msg) - puts "#{$describe} #{msg}" + spec = "#{$describe} #{msg}" + puts spec $befores.each { |x| x.call } - yield + begin + yield + rescue => exc + puts "ERROR: Exception happened: #{exc}" + $specs_exceptions += 1 + end + $specs_total += 1 $afters.each { |x| x.call } end @@ -170,6 +179,6 @@ class MainActivity < Android::App::Activity $describe = ary[0] ary[1].call end - puts "Spec suite finished: #{$expectations_total} expectations, #{$expectations_failures} failure(s)." + puts "Spec suite finished: #{$specs_total} specs, #{$specs_exceptions} exception(s), #{$expectations_total} expectations, #{$expectations_failures} failure(s)" end end