sapphire 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sapphire +45 -19
- data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +4 -0
- data/lib/sapphire/DSL/TestPlans/Run.rb +14 -2
- data/lib/sapphire/DSL/TestPlans/TestPlan.rb +1 -1
- data/lib/sapphire/Testing/ConsoleReporter.rb +2 -2
- data/lib/sapphire/Testing/Executable.rb +1 -1
- data/lib/sapphire/Testing/HtmlReporter.rb +45 -0
- data/lib/sapphire/Testing/TestRunnerAdapter.rb +1 -1
- data/lib/sapphire/version.rb +1 -1
- metadata +8 -8
data/bin/sapphire
CHANGED
@@ -5,42 +5,68 @@ require 'sapphire'
|
|
5
5
|
include Sapphire::Sapphire
|
6
6
|
|
7
7
|
$reporters = []
|
8
|
+
$instances = []
|
8
9
|
|
9
10
|
ARGV.each do |arg|
|
11
|
+
if arg.start_with? "reporter="
|
12
|
+
item = arg.split "reporter="
|
13
|
+
$reporters << item.last
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
next
|
16
|
+
end
|
17
|
+
|
18
|
+
if arg.start_with? "file="
|
19
|
+
item = arg.split "file="
|
20
|
+
@file = item.last
|
21
|
+
next
|
22
|
+
end
|
16
23
|
|
17
24
|
if !arg.end_with? ".rb"
|
18
25
|
next
|
19
26
|
end
|
20
27
|
|
21
28
|
require arg
|
22
|
-
Runner.instance.last_scenario.file_name = arg if Runner.instance.last_scenario and Runner.instance.last_scenario.file_name == ""
|
23
|
-
end
|
24
29
|
|
25
|
-
if
|
26
|
-
$reporters << ConsoleReporter.new()
|
30
|
+
Runner.instance.last_scenario.file_name = arg if Runner.instance.last_scenario and Runner.instance.last_scenario.file_name == ""
|
27
31
|
end
|
28
32
|
|
29
33
|
def Report(&block)
|
30
|
-
$
|
34
|
+
$instances.each do |reporter|
|
31
35
|
block.call reporter
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
def Process()
|
40
|
+
$reporters.each do |r|
|
41
|
+
$instances << Object.const_get(r).new()
|
42
|
+
$instances.last.file = @file if $instances.last.is_a? HtmlReporter
|
43
|
+
end
|
39
44
|
|
40
|
-
|
41
|
-
|
45
|
+
if $instances.empty?
|
46
|
+
$instances << ConsoleReporter.new()
|
42
47
|
end
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
if Runner.instance.test_plans.count > 0
|
50
|
+
Runner.instance.last_test_plan.execute
|
51
|
+
else
|
52
|
+
Report do |x| x.BeginTesting end
|
53
|
+
|
54
|
+
Runner.instance.scenarios.each do |scenario|
|
55
|
+
scenario.execute
|
56
|
+
end
|
57
|
+
|
58
|
+
Report do |x| x.TestingComplete end
|
59
|
+
Report do |x| x.OutputResults end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if @file.nil?
|
64
|
+
Process()
|
65
|
+
else
|
66
|
+
File.open(@file, 'w') do |f|
|
67
|
+
$stdout = f
|
68
|
+
Process()
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
@@ -5,10 +5,22 @@ module Sapphire
|
|
5
5
|
if(item.is_a? Job)
|
6
6
|
job = item
|
7
7
|
if(job.Arg)
|
8
|
-
|
8
|
+
@command = job.Path + " " + job.Arg.to_s
|
9
9
|
else
|
10
|
-
|
10
|
+
@command = job.Path
|
11
11
|
end
|
12
|
+
|
13
|
+
psFile = "C:\\runjob.ps1"
|
14
|
+
psCommand = "& icm " + job.Server + " {" + @command + "}"
|
15
|
+
File.open(psFile, 'w') {|f| f.write(psCommand) }
|
16
|
+
puts ""
|
17
|
+
puts ""
|
18
|
+
puts "executing your job via powershell command: " + psCommand
|
19
|
+
system "powershell -inputformat none " + psFile
|
20
|
+
File.delete(psFile)
|
21
|
+
puts ""
|
22
|
+
puts ""
|
23
|
+
|
12
24
|
else
|
13
25
|
Runner.instance.last_test_plan.Add(item)
|
14
26
|
end
|
@@ -1,7 +1,12 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
|
1
4
|
module Sapphire
|
2
5
|
module Testing
|
3
6
|
class HtmlReporter < Reporter
|
4
7
|
|
8
|
+
attr_accessor :file
|
9
|
+
|
5
10
|
def initialize()
|
6
11
|
@failures = []
|
7
12
|
@example_group_number = 0
|
@@ -11,6 +16,7 @@ module Sapphire
|
|
11
16
|
@broken_count = 0
|
12
17
|
@test_count = 0
|
13
18
|
@output = $stdout
|
19
|
+
@file = ""
|
14
20
|
end
|
15
21
|
|
16
22
|
def TestStarted(test)
|
@@ -49,6 +55,14 @@ module Sapphire
|
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
58
|
+
content = []
|
59
|
+
content << "<span>"
|
60
|
+
|
61
|
+
file_name = save_screenshot
|
62
|
+
content << link_for(file_name)
|
63
|
+
|
64
|
+
content << "</span>"
|
65
|
+
@output.puts content
|
52
66
|
@output.puts " </div>"
|
53
67
|
@output.puts " </dd>"
|
54
68
|
end
|
@@ -306,6 +320,37 @@ a {
|
|
306
320
|
}
|
307
321
|
EOF
|
308
322
|
end
|
323
|
+
|
324
|
+
def save_screenshot
|
325
|
+
if(!$driver)
|
326
|
+
return
|
327
|
+
end
|
328
|
+
|
329
|
+
begin
|
330
|
+
file_name = file_path("image.png")
|
331
|
+
$driver.Screenshot(file_name)
|
332
|
+
rescue => e
|
333
|
+
$stderr.puts "saving of screenshot failed."
|
334
|
+
$stderr.puts e.backtrace
|
335
|
+
end
|
336
|
+
file_name
|
337
|
+
end
|
338
|
+
|
339
|
+
def file_path(file_name)
|
340
|
+
extension = File.extname(file_name)
|
341
|
+
basename = File.basename(file_name, extension)
|
342
|
+
dir = File.dirname(@file)
|
343
|
+
file_path = File.join(dir, "", "#{basename}_#{Time.now.strftime("%H%M%S")}#{extension}")
|
344
|
+
file_path
|
345
|
+
end
|
346
|
+
|
347
|
+
def link_for(file_name)
|
348
|
+
return unless file_name && File.exists?(file_name)
|
349
|
+
|
350
|
+
path = Pathname.new(file_name)
|
351
|
+
|
352
|
+
"<a href='#{File.basename(path)}'>Screenshot</a> "
|
353
|
+
end
|
309
354
|
end
|
310
355
|
end
|
311
356
|
end
|
data/lib/sapphire/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.9
|
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-
|
12
|
+
date: 2012-03-14 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &9714480 !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: *
|
24
|
+
version_requirements: *9714480
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9714228 !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: *
|
35
|
+
version_requirements: *9714228
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &9713976 !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: *
|
46
|
+
version_requirements: *9713976
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|