Skip to content

Commit

Permalink
adding support for nested test plans
Browse files Browse the repository at this point in the history
  • Loading branch information
ot-marcus-bratton committed Mar 23, 2012
1 parent 2d314be commit 81e06a1
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 39 deletions.
11 changes: 9 additions & 2 deletions bin/sapphire
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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|
Expand Down
4 changes: 2 additions & 2 deletions lib/sapphire/DSL/TestPlans/FileHandler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions lib/sapphire/DSL/TestPlans/TestPlan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def initialize(text, &block)

AddHandler :file => FileHandler.new
AddHandler :path => PathHandler.new

end

def Cover(item)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/sapphire/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Sapphire
VERSION = "0.7.17"
VERSION = "0.7.18"
end
14 changes: 14 additions & 0 deletions tests/BasicPage/TestPlans/NestedTestPlans.rb
Original file line number Diff line number Diff line change
@@ -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
47 changes: 22 additions & 25 deletions tests/BasicPage/TestPlans/Regression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 81e06a1

Please sign in to comment.