sapphire 0.7.21 → 0.7.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,11 @@ $instances = []
10
10
 
11
11
 
12
12
  if ENV["reporter"]
13
- $reporters << ENV["reporter"]
13
+ reporters = ENV["reporter"].split(',')
14
+
15
+ reporters.each do |r|
16
+ $reporters << r
17
+ end
14
18
  end
15
19
 
16
20
  if ENV["file"]
@@ -33,12 +37,14 @@ def Report(&block)
33
37
  end
34
38
 
35
39
  def Process()
40
+ ignore_console = false
36
41
  $reporters.each do |r|
37
42
  $instances << Object.const_get(r).new()
38
43
  $instances.last.file = @file if $instances.last.is_a? HtmlReporter
44
+ ignore_console = true if $instances.last.is_a? TeamCityReporter
39
45
  end
40
46
 
41
- $instances << ConsoleReporter.new()
47
+ $instances << ConsoleReporter.new() if !ignore_console
42
48
 
43
49
  if Runner.instance.test_plans.count > 0
44
50
  Report do |x| x.BeginTesting end
@@ -59,9 +65,11 @@ def Process()
59
65
 
60
66
  Report do |x| x.TestingComplete end
61
67
  Report do |x| x.OutputResults end
68
+
62
69
  end
63
70
  end
64
71
 
72
+
65
73
  if @file.nil?
66
74
  Process()
67
75
  else
@@ -71,4 +79,3 @@ else
71
79
  end
72
80
  end
73
81
 
74
-
@@ -26,12 +26,12 @@ module Sapphire
26
26
  include DSL::Configuration
27
27
  include DSL::Data
28
28
  include DSL::TestPlans
29
+ include DSL::Coverage
29
30
  include Configuration
30
31
  include DataAbstractions
31
32
  include JobAbstractions
32
33
  include WebAbstractions
33
34
  include Testing
34
- include Testing::Coverage
35
35
  include Testing::TeamCity
36
36
  include UI
37
37
  end
@@ -13,3 +13,4 @@ Dir[File.dirname(__FILE__) + '/DSL/Configuration/*.rb'].each {|file| require fil
13
13
  Dir[File.dirname(__FILE__) + '/DSL/Data/*.rb'].each {|file| require file }
14
14
  Dir[File.dirname(__FILE__) + '/DSL/Scenarios/*.rb'].each {|file| require file }
15
15
  Dir[File.dirname(__FILE__) + '/DSL/Events/*.rb'].each {|file| require file }
16
+ Dir[File.dirname(__FILE__) + '/DSL/Coverage/*.rb'].each {|file| require file }
@@ -1,5 +1,5 @@
1
1
  module Sapphire
2
- module Testing
2
+ module DSL
3
3
  module Coverage
4
4
  def Behavior(token, hash)
5
5
  $features.last().AddBehavior(Behavior.new(token, hash))
@@ -1,6 +1,10 @@
1
1
  module Sapphire
2
- module Testing
2
+ module DSL
3
3
  module Coverage
4
+ #def Covers(item)
5
+ # Runner.instance.last_test_plan.Cover(item)
6
+ #end
7
+
4
8
  def Covers(hash)
5
9
  token = hash.keys.first
6
10
  target = hash[hash.keys.first]
@@ -9,14 +13,13 @@ module Sapphire
9
13
  $current_feature = target
10
14
  elsif(token == :requirement)
11
15
  $current_rule = target
12
- elsif(token == :test)
16
+ elsif(token == :behavior)
13
17
  feature = $features.select { |f| f.token == $current_feature }[0]
14
18
  requirement = feature.requirements.select { |r| r.token == $current_rule }[0]
15
- test = requirement.tests.select { |t| t.token == target }[0]
19
+ test = requirement.behaviors.select { |t| t.token == target }[0]
16
20
  test.is_covered = true
17
21
  end
18
-
19
22
  end
20
23
  end
21
24
  end
22
- end
25
+ end
@@ -0,0 +1,9 @@
1
+ module Sapphire
2
+ module DSL
3
+ module Coverage
4
+ def Describe(text)
5
+ $features.last().Describe(text)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module Sapphire
2
- module Testing
2
+ module DSL
3
3
  module Coverage
4
4
  def Feature(token, &block)
5
5
  $features ||= []
@@ -25,6 +25,10 @@ module Sapphire
25
25
  @requirements.last().AddBehavior behavior
26
26
  end
27
27
 
28
+ def Describe(text)
29
+
30
+ end
31
+
28
32
  end
29
33
  end
30
34
  end
@@ -1,8 +1,8 @@
1
1
  module Sapphire
2
- module Testing
2
+ module DSL
3
3
  module Coverage
4
- def Requirement(hash, &block)
5
- $features.last.AddRequirement(Requirement.new(hash))
4
+ def Requirement(token, hash, &block)
5
+ $features.last.AddRequirement(Requirement.new(token, hash))
6
6
  block.call
7
7
  end
8
8
 
@@ -12,8 +12,8 @@ module Sapphire
12
12
  attr_reader :priority
13
13
  attr_reader :behaviors
14
14
 
15
- def initialize(hash)
16
- @token = hash.keys.first
15
+ def initialize(token, hash)
16
+ @token = token
17
17
  @priority = hash[hash.keys.first]
18
18
  @behaviors = []
19
19
  end
@@ -1,4 +1,4 @@
1
- Dir[File.dirname(__FILE__) + '/TeamCity/*.rb'].each {|file| require file } if ENV["TeamCity"] == 1
1
+ Dir[File.dirname(__FILE__) + '/TeamCity/*.rb'].each {|file| require file } if ENV["TeamCity"] == "1"
2
2
 
3
3
  module Sapphire
4
4
  module Testing
@@ -0,0 +1,61 @@
1
+ module Sapphire
2
+ module Testing
3
+ class CoverageReporter
4
+
5
+ def initialize()
6
+ @output = $stdout
7
+ end
8
+
9
+ def OutputResults()
10
+ @output.puts ""
11
+
12
+ $features.each do |feature|
13
+ @output.puts "Feature: " + feature.token.to_s
14
+
15
+ feature.requirements.each do |requirement|
16
+ @output.puts "\tRequirement: " + requirement.token.to_s
17
+
18
+
19
+ positiveCount = 0
20
+ negativeCount = 0
21
+ boundaryCount = 0
22
+ exceptionCount = 0
23
+
24
+ expectedPositiveCount = 0
25
+ expectedNegativeCount = 0
26
+ expectedBoundaryCount = 0
27
+ expectedExceptionCount = 0
28
+
29
+ requirement.behaviors.each do |behavior|
30
+
31
+ if behavior.type == :positive
32
+ positiveCount += 1 if behavior.is_covered
33
+ expectedPositiveCount += 1
34
+ end
35
+
36
+ if behavior.type == :negative
37
+ negativeCount += 1 if behavior.is_covered
38
+ expectedNegativeCount += 1
39
+ end
40
+
41
+ if behavior.type == :boundary
42
+ boundaryCount += 1 if behavior.is_covered
43
+ expectedBoundaryCount += 1
44
+ end
45
+
46
+ if behavior.type == :exception
47
+ exceptionCount += 1 if behavior.is_covered
48
+ expectedExceptionCount += 1
49
+ end
50
+ end
51
+
52
+ @output.puts "\t\tPositive: " + positiveCount.to_s + "/" + expectedPositiveCount.to_s + " covered."
53
+ @output.puts "\t\tNegative: " + negativeCount.to_s + "/" + expectedNegativeCount.to_s + " covered."
54
+ @output.puts "\t\tBoundary: " + boundaryCount.to_s + "/" + expectedBoundaryCount.to_s + " covered."
55
+ @output.puts "\t\tException: " + exceptionCount.to_s + "/" + expectedExceptionCount.to_s + " covered."
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module Sapphire
2
- VERSION = "0.7.21"
2
+ VERSION = "0.7.22"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapphire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.21
4
+ version: 0.7.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000Z
12
+ date: 2012-04-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: selenium-webdriver
16
- requirement: &9679440 !ruby/object:Gem::Requirement
16
+ requirement: &9789756 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9679440
24
+ version_requirements: *9789756
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: colorize
27
- requirement: &9679188 !ruby/object:Gem::Requirement
27
+ requirement: &9789504 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *9679188
35
+ version_requirements: *9789504
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: Platform
38
- requirement: &9678936 !ruby/object:Gem::Requirement
38
+ requirement: &9789252 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *9678936
46
+ version_requirements: *9789252
47
47
  description: An automated web acceptance test framework for non-technical resources
48
48
  using selenium-wedriver.
49
49
  email:
@@ -115,6 +115,11 @@ files:
115
115
  - lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb
116
116
  - lib/sapphire/DSL/Configuration/ConfiguredUser.rb
117
117
  - lib/sapphire/DSL/Configuration/Use.rb
118
+ - lib/sapphire/DSL/Coverage/Behavior.rb
119
+ - lib/sapphire/DSL/Coverage/Covers.rb
120
+ - lib/sapphire/DSL/Coverage/Describe.rb
121
+ - lib/sapphire/DSL/Coverage/Feature.rb
122
+ - lib/sapphire/DSL/Coverage/Requirement.rb
118
123
  - lib/sapphire/DSL/Data/Find.rb
119
124
  - lib/sapphire/DSL/Data/GetPageField.rb
120
125
  - lib/sapphire/DSL/Data/Verify.rb
@@ -150,7 +155,6 @@ files:
150
155
  - lib/sapphire/DSL/Scenarios/scenario.rb
151
156
  - lib/sapphire/DSL/Scenarios/then.rb
152
157
  - lib/sapphire/DSL/Scenarios/when.rb
153
- - lib/sapphire/DSL/TestPlans/Covers.rb
154
158
  - lib/sapphire/DSL/TestPlans/FileHandler.rb
155
159
  - lib/sapphire/DSL/TestPlans/Parameter.rb
156
160
  - lib/sapphire/DSL/TestPlans/PathHandler.rb
@@ -168,10 +172,7 @@ files:
168
172
  - lib/sapphire/TeamCity/TeamCityReporter.rb
169
173
  - lib/sapphire/TeamCity.rb
170
174
  - lib/sapphire/Testing/ConsoleReporter.rb
171
- - lib/sapphire/Testing/Coverage/Behavior.rb
172
- - lib/sapphire/Testing/Coverage/Covers.rb
173
- - lib/sapphire/Testing/Coverage/Feature.rb
174
- - lib/sapphire/Testing/Coverage/Requirement.rb
175
+ - lib/sapphire/Testing/CoverageReporter.rb
175
176
  - lib/sapphire/Testing/Executable.rb
176
177
  - lib/sapphire/Testing/ExpectationException.rb
177
178
  - lib/sapphire/Testing/HtmlReporter.rb
@@ -1,9 +0,0 @@
1
- module Sapphire
2
- module DSL
3
- module TestPlans
4
- def Covers(item)
5
- Runner.instance.last_test_plan.Cover(item)
6
- end
7
- end
8
- end
9
- end