From 81e06a19d79d9988d7aa3b3e372aa67a8f818b7f Mon Sep 17 00:00:00 2001 From: Marcus Bratton Date: Fri, 23 Mar 2012 15:58:18 -0500 Subject: [PATCH] adding support for nested test plans --- bin/sapphire | 11 ++++- lib/sapphire/DSL/TestPlans/FileHandler.rb | 4 +- lib/sapphire/DSL/TestPlans/TestPlan.rb | 19 ++++---- lib/sapphire/version.rb | 2 +- tests/BasicPage/TestPlans/NestedTestPlans.rb | 14 ++++++ tests/BasicPage/TestPlans/Regression.rb | 47 +++++++++----------- 6 files changed, 58 insertions(+), 39 deletions(-) create mode 100644 tests/BasicPage/TestPlans/NestedTestPlans.rb diff --git a/bin/sapphire b/bin/sapphire index 9cf1381..b336854 100755 --- a/bin/sapphire +++ b/bin/sapphire @@ -23,7 +23,6 @@ ARGV.each do |arg| require arg - Runner.instance.last_scenario.file_name = arg if Runner.instance.last_scenario and Runner.instance.last_scenario.file_name == "" end def Report(&block) @@ -43,8 +42,16 @@ def Process() end if Runner.instance.test_plans.count > 0 - Runner.instance.last_test_plan.execute + Report do |x| x.BeginTesting end + + Runner.instance.test_plans.each do |t| + t.execute + end + + Report do |x| x.TestingComplete end + Report do |x| x.OutputResults end else + Report do |x| x.BeginTesting end Runner.instance.scenarios.each do |scenario| diff --git a/lib/sapphire/DSL/TestPlans/FileHandler.rb b/lib/sapphire/DSL/TestPlans/FileHandler.rb index de8fc1b..a171655 100644 --- a/lib/sapphire/DSL/TestPlans/FileHandler.rb +++ b/lib/sapphire/DSL/TestPlans/FileHandler.rb @@ -10,8 +10,8 @@ def Handle(item) file = File.expand_path(File.dirname(__FILE__) + item) if !File.exists?(file) raise "File Not Found: " + item if !File.exists?(file) load file if File.exists?(file) - Runner.instance.last_scenario.file_name = item - Runner.instance.last_scenario.execute + Runner.instance.last_scenario.file_name = item if Runner.instance.last_scenario and Runner.instance.last_scenario.file_name == "" + #Runner.instance.last_scenario.execute end end end diff --git a/lib/sapphire/DSL/TestPlans/TestPlan.rb b/lib/sapphire/DSL/TestPlans/TestPlan.rb index 80ee0f2..ea6266b 100644 --- a/lib/sapphire/DSL/TestPlans/TestPlan.rb +++ b/lib/sapphire/DSL/TestPlans/TestPlan.rb @@ -23,6 +23,7 @@ def initialize(text, &block) AddHandler :file => FileHandler.new AddHandler :path => PathHandler.new + end def Cover(item) @@ -46,15 +47,15 @@ def AddHandler(handler) end def execute - Report do |x| x.BeginTesting end - $stdout.puts "" - begin - @block.call - rescue => e - Report do |x| x.TestFailed TestPlanResult.new('fail', self, e.message, e.backtrace, 0) end - end - Report do |x| x.TestingComplete end - Report do |x| x.OutputResults end + #Report do |x| x.BeginTesting end + #$stdout.puts "" + #begin + @block.call + #rescue => e + # Report do |x| x.TestFailed TestPlanResult.new('fail', self, e.message, e.backtrace, 0) end + #end + #Report do |x| x.TestingComplete end + #Report do |x| x.OutputResults end end def Report(&block) diff --git a/lib/sapphire/version.rb b/lib/sapphire/version.rb index c22f95c..f473202 100644 --- a/lib/sapphire/version.rb +++ b/lib/sapphire/version.rb @@ -1,3 +1,3 @@ module Sapphire - VERSION = "0.7.17" + VERSION = "0.7.18" end diff --git a/tests/BasicPage/TestPlans/NestedTestPlans.rb b/tests/BasicPage/TestPlans/NestedTestPlans.rb new file mode 100644 index 0000000..4876b03 --- /dev/null +++ b/tests/BasicPage/TestPlans/NestedTestPlans.rb @@ -0,0 +1,14 @@ +require File.expand_path('../../includes', File.dirname(__FILE__)) + +TestPlan "Sapphire Regression" do + + Virtually do + + Parameter :test_plans_path => File.expand_path(File.dirname(__FILE__), __FILE__) + + Run :file => :test_plans_path + "/Regression.rb" + Run :file => :test_plans_path + "/Regression.rb" + + end + +end \ No newline at end of file diff --git a/tests/BasicPage/TestPlans/Regression.rb b/tests/BasicPage/TestPlans/Regression.rb index 3a61b31..2ab656c 100644 --- a/tests/BasicPage/TestPlans/Regression.rb +++ b/tests/BasicPage/TestPlans/Regression.rb @@ -2,38 +2,35 @@ TestPlan "Sapphire Regression" do - Virtually do + Parameter :specs_path => File.expand_path(File.dirname(__FILE__) + "/../Specs/", __FILE__) - Parameter :specs_path => File.expand_path(File.dirname(__FILE__) + "/../Specs/", __FILE__) + Run :file => :specs_path + "/BrowserSpecs.rb" - Run :file => :specs_path + "/BrowserSpecs.rb" + Start FireFox With "" + Navigate To BasicPage - Start FireFox With "" - Navigate To BasicPage + Run :path => :specs_path + "/Controls/" + Run :path => :specs_path + "/Verbs/" + Run :path => :specs_path + "/Evaluators/" - Run :path => :specs_path + "/Controls/" - Run :path => :specs_path + "/Verbs/" - Run :path => :specs_path + "/Evaluators/" - - Create Matrix :test_grid do - Using :description => "Test 1", - :user_first_name => "John", - :user_last_name => "Doe" - Using :description => "Test 2", - :user_first_name => "John222", - :user_last_name => "Doe" - end + Create Matrix :test_grid do + Using :description => "Test 1", + :user_first_name => "John", + :user_last_name => "Doe" + Using :description => "Test 2", + :user_first_name => "John222", + :user_last_name => "Doe" + end - Using Matrix :test_grid do - Run :file => :specs_path + "/Matrix/MatrixSpecs.rb" - end + Using Matrix :test_grid do + Run :file => :specs_path + "/Matrix/MatrixSpecs.rb" + end - Run :path => :specs_path + "/LanguageFeatures/" - #todo - /Verbs/MouseOver - #todo - /Verbs/Switch + Run :path => :specs_path + "/LanguageFeatures/" + #todo - /Verbs/MouseOver + #todo - /Verbs/Switch - Exit Browser + Exit Browser - end end \ No newline at end of file