moto 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/moto +5 -5
- data/lib/cli.rb +1 -1
- data/lib/clients/website.rb +3 -3
- data/lib/empty_listener.rb +16 -16
- data/lib/exceptions/moto.rb +6 -6
- data/lib/exceptions/test_forced_failure.rb +6 -6
- data/lib/exceptions/test_forced_passed.rb +6 -6
- data/lib/exceptions/test_skipped.rb +6 -6
- data/lib/forward_context_methods.rb +20 -20
- data/lib/initializer.rb +6 -6
- data/lib/listeners/base.rb +25 -25
- data/lib/listeners/console.rb +28 -28
- data/lib/listeners/console_dots.rb +62 -62
- data/lib/listeners/junit_xml.rb +36 -36
- data/lib/result.rb +83 -83
- data/lib/runner_logging.rb +26 -26
- data/lib/test_generator.rb +1 -1
- data/lib/test_logging.rb +48 -48
- data/lib/thread_context.rb +2 -2
- data/lib/version.rb +1 -1
- metadata +25 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6340ddcd3b7bd29181c132c770e511ff057e7f65
|
4
|
+
data.tar.gz: 61b04ec015807b80fd7534b0df79675bfe341b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b6d8ab0b350eee5e36020dc1fd290153f93761d2e09d167835b39ddd6f80395f86a98c584924a03d3dc7d8df5b8109c00839e83cfa6d1b1813f249b586cfb86
|
7
|
+
data.tar.gz: 9216bef294eefd81da2c88139ee1065f535365bfc5d09b6ff5e81dc43c63510f5e89f05ff7eed7c54e6eb16d7b9892d2d3c88de72e2c417f8b6bb6968d5e90cd
|
data/bin/moto
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative '../lib/parser'
|
4
|
-
|
5
|
-
Moto::Parser.run ARGV
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/parser'
|
4
|
+
|
5
|
+
Moto::Parser.run ARGV
|
data/lib/cli.rb
CHANGED
@@ -74,7 +74,7 @@ module Moto
|
|
74
74
|
if File.exists?( "#{MotoApp::DIR}/lib/initializer.rb" )
|
75
75
|
require("#{Moto::DIR}/lib/initializer.rb")
|
76
76
|
require("#{MotoApp::DIR}/lib/initializer.rb")
|
77
|
-
initializer = MotoApp::Initializer.new(self)
|
77
|
+
initializer = MotoApp::Lib::Initializer.new(self)
|
78
78
|
initializer.init
|
79
79
|
end
|
80
80
|
|
data/lib/clients/website.rb
CHANGED
@@ -35,14 +35,14 @@ module Moto
|
|
35
35
|
def end_test(test)
|
36
36
|
Thread.current['capybara_session'].reset_session!
|
37
37
|
end
|
38
|
-
|
38
|
+
#TODO fix moto to use Lib module
|
39
39
|
def page(p)
|
40
40
|
page_class_name = "#{self.class.name}::Pages::#{p}"
|
41
|
-
page_class_name.gsub!('Moto::', 'MotoApp::')
|
41
|
+
page_class_name.gsub!('Moto::', 'MotoApp::Lib::')
|
42
42
|
if @pages[page_class_name].nil?
|
43
43
|
a = page_class_name.underscore.split('/')
|
44
44
|
page_path = a[1..-1].join('/')
|
45
|
-
require "#{MotoApp::DIR}
|
45
|
+
require "#{MotoApp::DIR}/#{page_path}"
|
46
46
|
@pages[page_class_name] = page_class_name.constantize.new(self)
|
47
47
|
end
|
48
48
|
@pages[page_class_name]
|
data/lib/empty_listener.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
module Moto
|
2
|
-
module EmptyListener
|
3
|
-
|
4
|
-
def start_run
|
5
|
-
end
|
6
|
-
|
7
|
-
def end_run
|
8
|
-
end
|
9
|
-
|
10
|
-
def start_test(test)
|
11
|
-
end
|
12
|
-
|
13
|
-
def end_test(test)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
1
|
+
module Moto
|
2
|
+
module EmptyListener
|
3
|
+
|
4
|
+
def start_run
|
5
|
+
end
|
6
|
+
|
7
|
+
def end_run
|
8
|
+
end
|
9
|
+
|
10
|
+
def start_test(test)
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_test(test)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
17
|
end
|
data/lib/exceptions/moto.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class MotoException < RuntimeError
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class MotoException < RuntimeError
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class TestForcedFailure < MotoException
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class TestForcedFailure < MotoException
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class TestForcedPassed < MotoException
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class TestForcedPassed < MotoException
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
module Exceptions
|
3
|
-
class TestSkipped < MotoException
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Exceptions
|
3
|
+
class TestSkipped < MotoException
|
4
|
+
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
module Moto
|
2
|
-
module ForwardContextMethods
|
3
|
-
|
4
|
-
def client(name)
|
5
|
-
@context.client(name)
|
6
|
-
end
|
7
|
-
|
8
|
-
def logger
|
9
|
-
@context.logger
|
10
|
-
end
|
11
|
-
|
12
|
-
def const(key)
|
13
|
-
@context.const(key)
|
14
|
-
end
|
15
|
-
|
16
|
-
def current_test
|
17
|
-
@context.current_test
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
1
|
+
module Moto
|
2
|
+
module ForwardContextMethods
|
3
|
+
|
4
|
+
def client(name)
|
5
|
+
@context.client(name)
|
6
|
+
end
|
7
|
+
|
8
|
+
def logger
|
9
|
+
@context.logger
|
10
|
+
end
|
11
|
+
|
12
|
+
def const(key)
|
13
|
+
@context.const(key)
|
14
|
+
end
|
15
|
+
|
16
|
+
def current_test
|
17
|
+
@context.current_test
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
21
|
end
|
data/lib/initializer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module Moto
|
2
|
-
class Initializer
|
3
|
-
def initialize(runner)
|
4
|
-
@runner = runner
|
5
|
-
end
|
6
|
-
end
|
1
|
+
module Moto
|
2
|
+
class Initializer
|
3
|
+
def initialize(runner)
|
4
|
+
@runner = runner
|
5
|
+
end
|
6
|
+
end
|
7
7
|
end
|
data/lib/listeners/base.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
module Moto
|
2
|
-
module Listeners
|
3
|
-
class Base
|
4
|
-
|
5
|
-
def initialize(runner)
|
6
|
-
@runner=runner
|
7
|
-
end
|
8
|
-
|
9
|
-
def start_run
|
10
|
-
# abstract
|
11
|
-
end
|
12
|
-
|
13
|
-
def end_run
|
14
|
-
# abstract
|
15
|
-
end
|
16
|
-
|
17
|
-
def start_test(test)
|
18
|
-
# abstract
|
19
|
-
end
|
20
|
-
|
21
|
-
def end_test(test)
|
22
|
-
# abstract
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Listeners
|
3
|
+
class Base
|
4
|
+
|
5
|
+
def initialize(runner)
|
6
|
+
@runner=runner
|
7
|
+
end
|
8
|
+
|
9
|
+
def start_run
|
10
|
+
# abstract
|
11
|
+
end
|
12
|
+
|
13
|
+
def end_run
|
14
|
+
# abstract
|
15
|
+
end
|
16
|
+
|
17
|
+
def start_test(test)
|
18
|
+
# abstract
|
19
|
+
end
|
20
|
+
|
21
|
+
def end_test(test)
|
22
|
+
# abstract
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
26
|
end
|
data/lib/listeners/console.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
module Moto
|
2
|
-
module Listeners
|
3
|
-
class Console < Base
|
4
|
-
|
5
|
-
def start_run
|
6
|
-
puts "START"
|
7
|
-
end
|
8
|
-
|
9
|
-
def end_run
|
10
|
-
puts ""
|
11
|
-
puts "FINISHED: #{@runner.result.summary[:result]}, duration: #{Time.at(@runner.result.summary[:duration]).utc.strftime("%H:%M:%S")}"
|
12
|
-
puts "Tests executed: #{@runner.result.summary[:cnt_all]}"
|
13
|
-
puts " Passed: #{@runner.result.summary[:cnt_passed]}"
|
14
|
-
puts " Failure: #{@runner.result.summary[:cnt_failure]}"
|
15
|
-
puts " Error: #{@runner.result.summary[:cnt_error]}"
|
16
|
-
puts " Skipped: #{@runner.result.summary[:cnt_skipped]}"
|
17
|
-
end
|
18
|
-
|
19
|
-
def start_test(test)
|
20
|
-
print test.name
|
21
|
-
end
|
22
|
-
|
23
|
-
def end_test(test)
|
24
|
-
puts "\t#{@runner.result[test.name][:result]}"
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Listeners
|
3
|
+
class Console < Base
|
4
|
+
|
5
|
+
def start_run
|
6
|
+
puts "START"
|
7
|
+
end
|
8
|
+
|
9
|
+
def end_run
|
10
|
+
puts ""
|
11
|
+
puts "FINISHED: #{@runner.result.summary[:result]}, duration: #{Time.at(@runner.result.summary[:duration]).utc.strftime("%H:%M:%S")}"
|
12
|
+
puts "Tests executed: #{@runner.result.summary[:cnt_all]}"
|
13
|
+
puts " Passed: #{@runner.result.summary[:cnt_passed]}"
|
14
|
+
puts " Failure: #{@runner.result.summary[:cnt_failure]}"
|
15
|
+
puts " Error: #{@runner.result.summary[:cnt_error]}"
|
16
|
+
puts " Skipped: #{@runner.result.summary[:cnt_skipped]}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def start_test(test)
|
20
|
+
print test.name
|
21
|
+
end
|
22
|
+
|
23
|
+
def end_test(test)
|
24
|
+
puts "\t#{@runner.result[test.name][:result]}"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
29
|
end
|
@@ -1,63 +1,63 @@
|
|
1
|
-
module Moto
|
2
|
-
module Listeners
|
3
|
-
class ConsoleDots < Base
|
4
|
-
|
5
|
-
def start_run
|
6
|
-
end
|
7
|
-
|
8
|
-
def end_run
|
9
|
-
puts ""
|
10
|
-
puts ""
|
11
|
-
puts "FINISHED: #{@runner.result.summary[:result]}, duration: #{Time.at(@runner.result.summary[:duration]).utc.strftime("%H:%M:%S")}"
|
12
|
-
puts "Tests executed: #{@runner.result.summary[:cnt_all]}"
|
13
|
-
puts " Passed: #{@runner.result.summary[:cnt_passed]}"
|
14
|
-
puts " Failure: #{@runner.result.summary[:cnt_failure]}"
|
15
|
-
puts " Error: #{@runner.result.summary[:cnt_error]}"
|
16
|
-
puts " Skipped: #{@runner.result.summary[:cnt_skipped]}"
|
17
|
-
|
18
|
-
if @runner.result.summary[:cnt_failure] > 0
|
19
|
-
puts ""
|
20
|
-
puts "FAILURES: "
|
21
|
-
@runner.result.summary[:tests_failure].each do |test_name, data|
|
22
|
-
puts test_name
|
23
|
-
puts "\t#{data[:failures].join("\n\t")}"
|
24
|
-
puts ""
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
if @runner.result.summary[:cnt_error] > 0
|
29
|
-
puts ""
|
30
|
-
puts "ERRORS: "
|
31
|
-
@runner.result.summary[:tests_error].each do |test_name, data|
|
32
|
-
puts test_name
|
33
|
-
puts "\t#{data[:error]}"
|
34
|
-
puts ""
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
if @runner.result.summary[:cnt_skipped] > 0
|
39
|
-
puts ""
|
40
|
-
puts "SKIPPED: "
|
41
|
-
@runner.result.summary[:tests_skipped].each do |test_name, data|
|
42
|
-
puts test_name
|
43
|
-
puts "\t#{data[:error]}"
|
44
|
-
puts ""
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def start_test(test)
|
50
|
-
end
|
51
|
-
|
52
|
-
def end_test(test)
|
53
|
-
print case @runner.result[test.name][:result]
|
54
|
-
when :passed then "."
|
55
|
-
when :failure then "F"
|
56
|
-
when :error then "E"
|
57
|
-
when :skipped then "
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
1
|
+
module Moto
|
2
|
+
module Listeners
|
3
|
+
class ConsoleDots < Base
|
4
|
+
|
5
|
+
def start_run
|
6
|
+
end
|
7
|
+
|
8
|
+
def end_run
|
9
|
+
puts ""
|
10
|
+
puts ""
|
11
|
+
puts "FINISHED: #{@runner.result.summary[:result]}, duration: #{Time.at(@runner.result.summary[:duration]).utc.strftime("%H:%M:%S")}"
|
12
|
+
puts "Tests executed: #{@runner.result.summary[:cnt_all]}"
|
13
|
+
puts " Passed: #{@runner.result.summary[:cnt_passed]}"
|
14
|
+
puts " Failure: #{@runner.result.summary[:cnt_failure]}"
|
15
|
+
puts " Error: #{@runner.result.summary[:cnt_error]}"
|
16
|
+
puts " Skipped: #{@runner.result.summary[:cnt_skipped]}"
|
17
|
+
|
18
|
+
if @runner.result.summary[:cnt_failure] > 0
|
19
|
+
puts ""
|
20
|
+
puts "FAILURES: "
|
21
|
+
@runner.result.summary[:tests_failure].each do |test_name, data|
|
22
|
+
puts test_name
|
23
|
+
puts "\t#{data[:failures].join("\n\t")}"
|
24
|
+
puts ""
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if @runner.result.summary[:cnt_error] > 0
|
29
|
+
puts ""
|
30
|
+
puts "ERRORS: "
|
31
|
+
@runner.result.summary[:tests_error].each do |test_name, data|
|
32
|
+
puts test_name
|
33
|
+
puts "\t#{data[:error]}"
|
34
|
+
puts ""
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if @runner.result.summary[:cnt_skipped] > 0
|
39
|
+
puts ""
|
40
|
+
puts "SKIPPED: "
|
41
|
+
@runner.result.summary[:tests_skipped].each do |test_name, data|
|
42
|
+
puts test_name
|
43
|
+
puts "\t#{data[:error]}"
|
44
|
+
puts ""
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def start_test(test)
|
50
|
+
end
|
51
|
+
|
52
|
+
def end_test(test)
|
53
|
+
print case @runner.result[test.name][:result]
|
54
|
+
when :passed then "."
|
55
|
+
when :failure then "F"
|
56
|
+
when :error then "E"
|
57
|
+
when :skipped then "s"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
63
|
end
|
data/lib/listeners/junit_xml.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module Moto
|
4
|
-
module Listeners
|
5
|
-
class JunitXml < Base
|
6
|
-
|
7
|
-
def end_run
|
8
|
-
path = @runner.my_config[:output_file]
|
9
|
-
|
10
|
-
builder = Nokogiri::XML::Builder.new { |xml|
|
11
|
-
xml.testsuite(
|
12
|
-
errors: @runner.result.summary[:cnt_error],
|
13
|
-
failures: @runner.result.summary[:cnt_failure],
|
14
|
-
name: "Moto run",
|
15
|
-
tests: @runner.result.summary[:cnt_all],
|
16
|
-
time: @runner.result.summary[:duration],
|
17
|
-
timestamp: Time.at(@runner.result.summary[:started_at])) do
|
18
|
-
@runner.result.all.each do |test_name, data|
|
19
|
-
xml.testcase(name: test_name, time: data[:duration], classname: data[:class].name, moto_result: data[:result]) do
|
20
|
-
if !data[:error].nil?
|
21
|
-
xml.error(message: data[:error].message)
|
22
|
-
elsif data[:failures].count > 0
|
23
|
-
data[:failures].each do |f|
|
24
|
-
xml.failure(message: f)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
}
|
31
|
-
|
32
|
-
File.open(path, 'w') {|f| f.write(builder.to_xml) }
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Moto
|
4
|
+
module Listeners
|
5
|
+
class JunitXml < Base
|
6
|
+
|
7
|
+
def end_run
|
8
|
+
path = @runner.my_config[:output_file]
|
9
|
+
|
10
|
+
builder = Nokogiri::XML::Builder.new { |xml|
|
11
|
+
xml.testsuite(
|
12
|
+
errors: @runner.result.summary[:cnt_error],
|
13
|
+
failures: @runner.result.summary[:cnt_failure],
|
14
|
+
name: "Moto run",
|
15
|
+
tests: @runner.result.summary[:cnt_all],
|
16
|
+
time: @runner.result.summary[:duration],
|
17
|
+
timestamp: Time.at(@runner.result.summary[:started_at])) do
|
18
|
+
@runner.result.all.each do |test_name, data|
|
19
|
+
xml.testcase(name: test_name, time: data[:duration], classname: data[:class].name, moto_result: data[:result]) do
|
20
|
+
if !data[:error].nil?
|
21
|
+
xml.error(message: data[:error].message)
|
22
|
+
elsif data[:failures].count > 0
|
23
|
+
data[:failures].each do |f|
|
24
|
+
xml.failure(message: f)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
}
|
31
|
+
|
32
|
+
File.open(path, 'w') {|f| f.write(builder.to_xml) }
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
37
|
end
|
data/lib/result.rb
CHANGED
@@ -1,84 +1,84 @@
|
|
1
|
-
module Moto
|
2
|
-
class Result
|
3
|
-
|
4
|
-
PENDING = :pending # -2
|
5
|
-
RUNNING = :running # -1
|
6
|
-
PASSED = :passed # 0
|
7
|
-
FAILURE = :failure # 1
|
8
|
-
ERROR = :error # 2
|
9
|
-
SKIPPED = :skipped # 3
|
10
|
-
|
11
|
-
attr_reader :summary
|
12
|
-
|
13
|
-
def [](key)
|
14
|
-
@results[key]
|
15
|
-
end
|
16
|
-
|
17
|
-
def all
|
18
|
-
@results
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(runner)
|
22
|
-
@runner = runner
|
23
|
-
@results = {}
|
24
|
-
@summary = {}
|
25
|
-
end
|
26
|
-
|
27
|
-
def start_run
|
28
|
-
# start timer
|
29
|
-
@summary[:started_at] = Time.now.to_f
|
30
|
-
end
|
31
|
-
|
32
|
-
def end_run
|
33
|
-
# info about duration and overall execution result
|
34
|
-
@summary[:finished_at] = Time.now.to_f
|
35
|
-
@summary[:duration] = @summary[:finished_at] - @summary[:started_at]
|
36
|
-
@summary[:result] = PASSED
|
37
|
-
@summary[:result] = FAILURE unless @results.values.select{ |v| v[:failures].count > 0 }.empty?
|
38
|
-
@summary[:result] = ERROR unless @results.values.select{ |v| v[:result] == ERROR }.empty?
|
39
|
-
@summary[:cnt_all] = @results.count
|
40
|
-
@summary[:tests_passed] = @results.select{ |k,v| v[:result] == PASSED }
|
41
|
-
@summary[:tests_failure] = @results.select{ |k,v| v[:result] == FAILURE }
|
42
|
-
@summary[:tests_error] = @results.select{ |k,v| v[:result] == ERROR }
|
43
|
-
@summary[:tests_skipped] = @results.select{ |k,v| v[:result] == SKIPPED }
|
44
|
-
@summary[:cnt_passed] = @summary[:tests_passed].count
|
45
|
-
@summary[:cnt_failure] = @summary[:tests_failure].count
|
46
|
-
@summary[:cnt_error] = @summary[:tests_error].count
|
47
|
-
@summary[:cnt_skipped] = @summary[:tests_skipped].count
|
48
|
-
end
|
49
|
-
|
50
|
-
def start_test(test)
|
51
|
-
@results[test.name] = { class: test.class, result: RUNNING, env: test.env, params: test.params, name: test.name, error: nil, failures: [], started_at: Time.now.to_f }
|
52
|
-
end
|
53
|
-
|
54
|
-
def end_test(test)
|
55
|
-
# calculate result basing on errors/failures
|
56
|
-
@results[test.name][:finished_at] = Time.now.to_f
|
57
|
-
test.result = PASSED
|
58
|
-
test.result = FAILURE unless @results[test.name][:failures].empty?
|
59
|
-
unless @results[test.name][:error].nil?
|
60
|
-
if @results[test.name][:error].is_a? Moto::Exceptions::TestSkipped
|
61
|
-
test.result = SKIPPED
|
62
|
-
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedPassed
|
63
|
-
test.result = PASSED
|
64
|
-
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedFailure
|
65
|
-
add_failure(test, @results[test.name][:error].message)
|
66
|
-
test.result = FAILURE
|
67
|
-
else
|
68
|
-
test.result = ERROR
|
69
|
-
end
|
70
|
-
end
|
71
|
-
@results[test.name][:duration] = @results[test.name][:finished_at] - @results[test.name][:started_at]
|
72
|
-
@results[test.name][:result] = test.result
|
73
|
-
end
|
74
|
-
|
75
|
-
def add_failure(test, msg)
|
76
|
-
@results[test.name][:failures] << msg
|
77
|
-
end
|
78
|
-
|
79
|
-
def add_error(test, e)
|
80
|
-
@results[test.name][:error] = e
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
1
|
+
module Moto
|
2
|
+
class Result
|
3
|
+
|
4
|
+
PENDING = :pending # -2
|
5
|
+
RUNNING = :running # -1
|
6
|
+
PASSED = :passed # 0
|
7
|
+
FAILURE = :failure # 1
|
8
|
+
ERROR = :error # 2
|
9
|
+
SKIPPED = :skipped # 3
|
10
|
+
|
11
|
+
attr_reader :summary
|
12
|
+
|
13
|
+
def [](key)
|
14
|
+
@results[key]
|
15
|
+
end
|
16
|
+
|
17
|
+
def all
|
18
|
+
@results
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(runner)
|
22
|
+
@runner = runner
|
23
|
+
@results = {}
|
24
|
+
@summary = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def start_run
|
28
|
+
# start timer
|
29
|
+
@summary[:started_at] = Time.now.to_f
|
30
|
+
end
|
31
|
+
|
32
|
+
def end_run
|
33
|
+
# info about duration and overall execution result
|
34
|
+
@summary[:finished_at] = Time.now.to_f
|
35
|
+
@summary[:duration] = @summary[:finished_at] - @summary[:started_at]
|
36
|
+
@summary[:result] = PASSED
|
37
|
+
@summary[:result] = FAILURE unless @results.values.select{ |v| v[:failures].count > 0 }.empty?
|
38
|
+
@summary[:result] = ERROR unless @results.values.select{ |v| v[:result] == ERROR }.empty?
|
39
|
+
@summary[:cnt_all] = @results.count
|
40
|
+
@summary[:tests_passed] = @results.select{ |k,v| v[:result] == PASSED }
|
41
|
+
@summary[:tests_failure] = @results.select{ |k,v| v[:result] == FAILURE }
|
42
|
+
@summary[:tests_error] = @results.select{ |k,v| v[:result] == ERROR }
|
43
|
+
@summary[:tests_skipped] = @results.select{ |k,v| v[:result] == SKIPPED }
|
44
|
+
@summary[:cnt_passed] = @summary[:tests_passed].count
|
45
|
+
@summary[:cnt_failure] = @summary[:tests_failure].count
|
46
|
+
@summary[:cnt_error] = @summary[:tests_error].count
|
47
|
+
@summary[:cnt_skipped] = @summary[:tests_skipped].count
|
48
|
+
end
|
49
|
+
|
50
|
+
def start_test(test)
|
51
|
+
@results[test.name] = { class: test.class, result: RUNNING, env: test.env, params: test.params, name: test.name, error: nil, failures: [], started_at: Time.now.to_f }
|
52
|
+
end
|
53
|
+
|
54
|
+
def end_test(test)
|
55
|
+
# calculate result basing on errors/failures
|
56
|
+
@results[test.name][:finished_at] = Time.now.to_f
|
57
|
+
test.result = PASSED
|
58
|
+
test.result = FAILURE unless @results[test.name][:failures].empty?
|
59
|
+
unless @results[test.name][:error].nil?
|
60
|
+
if @results[test.name][:error].is_a? Moto::Exceptions::TestSkipped
|
61
|
+
test.result = SKIPPED
|
62
|
+
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedPassed
|
63
|
+
test.result = PASSED
|
64
|
+
elsif @results[test.name][:error].is_a? Moto::Exceptions::TestForcedFailure
|
65
|
+
add_failure(test, @results[test.name][:error].message)
|
66
|
+
test.result = FAILURE
|
67
|
+
else
|
68
|
+
test.result = ERROR
|
69
|
+
end
|
70
|
+
end
|
71
|
+
@results[test.name][:duration] = @results[test.name][:finished_at] - @results[test.name][:started_at]
|
72
|
+
@results[test.name][:result] = test.result
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_failure(test, msg)
|
76
|
+
@results[test.name][:failures] << msg
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_error(test, e)
|
80
|
+
@results[test.name][:error] = e
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
84
|
end
|
data/lib/runner_logging.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
module Moto
|
2
|
-
module RunnerLogging
|
3
|
-
|
4
|
-
|
5
|
-
# TODO: merge it somehow with TestLogging. Parametrize logger object?
|
6
|
-
def self.included(cls)
|
7
|
-
def cls.method_added(name)
|
8
|
-
excluded_methods = Moto::EmptyListener.instance_methods(false)
|
9
|
-
excluded_methods << :new
|
10
|
-
excluded_methods << :initialize
|
11
|
-
# TODO: configure more excluded classes/methods
|
12
|
-
return if @added
|
13
|
-
@added = true # protect from recursion
|
14
|
-
original_method = "original_#{name}"
|
15
|
-
alias_method original_method, name
|
16
|
-
define_method(name) do |*args|
|
17
|
-
@context.runner.logger.debug("#{self.class.name}::#{__callee__} ENTER >>> #{args}") unless excluded_methods.include? name
|
18
|
-
result = send original_method, *args
|
19
|
-
@context.runner.logger.debug("#{self.class.name}::#{__callee__} LEAVE <<< #{result} ") unless excluded_methods.include? name
|
20
|
-
result
|
21
|
-
end
|
22
|
-
@added = false
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Moto
|
2
|
+
module RunnerLogging
|
3
|
+
|
4
|
+
|
5
|
+
# TODO: merge it somehow with TestLogging. Parametrize logger object?
|
6
|
+
def self.included(cls)
|
7
|
+
def cls.method_added(name)
|
8
|
+
excluded_methods = Moto::EmptyListener.instance_methods(false)
|
9
|
+
excluded_methods << :new
|
10
|
+
excluded_methods << :initialize
|
11
|
+
# TODO: configure more excluded classes/methods
|
12
|
+
return if @added
|
13
|
+
@added = true # protect from recursion
|
14
|
+
original_method = "original_#{name}"
|
15
|
+
alias_method original_method, name
|
16
|
+
define_method(name) do |*args|
|
17
|
+
@context.runner.logger.debug("#{self.class.name}::#{__callee__} ENTER >>> #{args}") unless excluded_methods.include? name
|
18
|
+
result = send original_method, *args
|
19
|
+
@context.runner.logger.debug("#{self.class.name}::#{__callee__} LEAVE <<< #{result} ") unless excluded_methods.include? name
|
20
|
+
result
|
21
|
+
end
|
22
|
+
@added = false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
data/lib/test_generator.rb
CHANGED
data/lib/test_logging.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
module Moto
|
2
|
-
module TestLogging
|
3
|
-
|
4
|
-
@@ignore_logging = []
|
5
|
-
|
6
|
-
def self.included(cls)
|
7
|
-
|
8
|
-
def cls.ignore_logging(method)
|
9
|
-
full_name = "#{self.name}::#{method}"
|
10
|
-
@@ignore_logging << full_name
|
11
|
-
end
|
12
|
-
|
13
|
-
def cls.method_added(name)
|
14
|
-
|
15
|
-
Moto::EmptyListener.instance_methods(false).each do |m|
|
16
|
-
full_name = "#{self.name}::#{m}"
|
17
|
-
@@ignore_logging << full_name unless @@ignore_logging.include? full_name
|
18
|
-
end
|
19
|
-
@@ignore_logging << "#{self.name}::new"
|
20
|
-
@@ignore_logging << "#{self.name}::initialize"
|
21
|
-
|
22
|
-
return if @added
|
23
|
-
@added = true # protect from recursion
|
24
|
-
original_method = "original_#{name}"
|
25
|
-
alias_method original_method, name
|
26
|
-
define_method(name) do |*args|
|
27
|
-
full_name = "#{self.class.name}::#{__callee__}"
|
28
|
-
# TODO: use self.class.ancestors to figure out if ancestor::__callee__ is not in @@ignore_logging
|
29
|
-
skip_logging = @@ignore_logging.include? full_name
|
30
|
-
unless skip_logging
|
31
|
-
self.class.ancestors.each do |a|
|
32
|
-
ancestor_name = "#{a.name}::#{__callee__}"
|
33
|
-
if @@ignore_logging.include? ancestor_name
|
34
|
-
skip_logging = true
|
35
|
-
break
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
@context.current_test.logger.debug("ENTER >>> #{self.class.name}::#{__callee__}(#{args})") unless skip_logging
|
40
|
-
result = send original_method, *args
|
41
|
-
@context.current_test.logger.debug("LEAVE <<< #{self.class.name}::#{__callee__} => #{result} ") unless skip_logging
|
42
|
-
result
|
43
|
-
end
|
44
|
-
@added = false
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
1
|
+
module Moto
|
2
|
+
module TestLogging
|
3
|
+
|
4
|
+
@@ignore_logging = []
|
5
|
+
|
6
|
+
def self.included(cls)
|
7
|
+
|
8
|
+
def cls.ignore_logging(method)
|
9
|
+
full_name = "#{self.name}::#{method}"
|
10
|
+
@@ignore_logging << full_name
|
11
|
+
end
|
12
|
+
|
13
|
+
def cls.method_added(name)
|
14
|
+
|
15
|
+
Moto::EmptyListener.instance_methods(false).each do |m|
|
16
|
+
full_name = "#{self.name}::#{m}"
|
17
|
+
@@ignore_logging << full_name unless @@ignore_logging.include? full_name
|
18
|
+
end
|
19
|
+
@@ignore_logging << "#{self.name}::new"
|
20
|
+
@@ignore_logging << "#{self.name}::initialize"
|
21
|
+
|
22
|
+
return if @added
|
23
|
+
@added = true # protect from recursion
|
24
|
+
original_method = "original_#{name}"
|
25
|
+
alias_method original_method, name
|
26
|
+
define_method(name) do |*args|
|
27
|
+
full_name = "#{self.class.name}::#{__callee__}"
|
28
|
+
# TODO: use self.class.ancestors to figure out if ancestor::__callee__ is not in @@ignore_logging
|
29
|
+
skip_logging = @@ignore_logging.include? full_name
|
30
|
+
unless skip_logging
|
31
|
+
self.class.ancestors.each do |a|
|
32
|
+
ancestor_name = "#{a.name}::#{__callee__}"
|
33
|
+
if @@ignore_logging.include? ancestor_name
|
34
|
+
skip_logging = true
|
35
|
+
break
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
@context.current_test.logger.debug("ENTER >>> #{self.class.name}::#{__callee__}(#{args})") unless skip_logging
|
40
|
+
result = send original_method, *args
|
41
|
+
@context.current_test.logger.debug("LEAVE <<< #{self.class.name}::#{__callee__} => #{result} ") unless skip_logging
|
42
|
+
result
|
43
|
+
end
|
44
|
+
@added = false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
49
|
end
|
data/lib/thread_context.rb
CHANGED
@@ -26,10 +26,10 @@ module Moto
|
|
26
26
|
def client(name)
|
27
27
|
return @clients[name] if @clients.key? name
|
28
28
|
|
29
|
-
name_app = 'MotoApp::Clients::' + name
|
29
|
+
name_app = 'MotoApp::Lib::Clients::' + name
|
30
30
|
name_moto = 'Moto::Clients::' + name
|
31
31
|
|
32
|
-
c = try_client(name_app, "#{MotoApp::DIR}/
|
32
|
+
c = try_client(name_app, "#{MotoApp::DIR}/")
|
33
33
|
unless c.nil?
|
34
34
|
@clients[name] = c
|
35
35
|
return c
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartek Wilczek
|
@@ -10,62 +10,62 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '3.2'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: nokogiri
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rest-client
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: sys-uname
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
description: This is a development version of a rails philosophy inspired framework
|
@@ -81,12 +81,24 @@ executables:
|
|
81
81
|
extensions: []
|
82
82
|
extra_rdoc_files: []
|
83
83
|
files:
|
84
|
+
- bin/moto
|
84
85
|
- lib/app_generator.rb
|
85
86
|
- lib/assert.rb
|
86
87
|
- lib/cli.rb
|
88
|
+
- lib/clients/base.rb
|
89
|
+
- lib/clients/website.rb
|
87
90
|
- lib/empty_listener.rb
|
91
|
+
- lib/exceptions/moto.rb
|
92
|
+
- lib/exceptions/test_forced_failure.rb
|
93
|
+
- lib/exceptions/test_forced_passed.rb
|
94
|
+
- lib/exceptions/test_skipped.rb
|
88
95
|
- lib/forward_context_methods.rb
|
89
96
|
- lib/initializer.rb
|
97
|
+
- lib/listeners/base.rb
|
98
|
+
- lib/listeners/console.rb
|
99
|
+
- lib/listeners/console_dots.rb
|
100
|
+
- lib/listeners/junit_xml.rb
|
101
|
+
- lib/listeners/webui.rb
|
90
102
|
- lib/page.rb
|
91
103
|
- lib/parser.rb
|
92
104
|
- lib/result.rb
|
@@ -98,18 +110,6 @@ files:
|
|
98
110
|
- lib/thread_context.rb
|
99
111
|
- lib/thread_pool.rb
|
100
112
|
- lib/version.rb
|
101
|
-
- lib/clients/base.rb
|
102
|
-
- lib/clients/website.rb
|
103
|
-
- lib/exceptions/moto.rb
|
104
|
-
- lib/exceptions/test_forced_failure.rb
|
105
|
-
- lib/exceptions/test_forced_passed.rb
|
106
|
-
- lib/exceptions/test_skipped.rb
|
107
|
-
- lib/listeners/base.rb
|
108
|
-
- lib/listeners/console.rb
|
109
|
-
- lib/listeners/console_dots.rb
|
110
|
-
- lib/listeners/junit_xml.rb
|
111
|
-
- lib/listeners/webui.rb
|
112
|
-
- bin/moto
|
113
113
|
homepage: https://github.com/bwilczek/moto
|
114
114
|
licenses:
|
115
115
|
- MIT
|
@@ -120,17 +120,17 @@ require_paths:
|
|
120
120
|
- lib
|
121
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - ~>
|
123
|
+
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '2.0'
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- -
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.2.5
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Moto - yet another web testing framework
|