devcreek 0.4 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +8 -1
- data/Rakefile +1 -1
- data/lib/devcreek.rb +2 -4
- data/lib/devcreek_logger.rb +17 -0
- data/lib/devcreek_metriccollector.rb +100 -0
- data/lib/devcreek_record_template.rb +4 -4
- data/lib/devcreek_specreporter.rb +7 -53
- data/lib/devcreek_testrunnermediator.rb +7 -42
- data/lib/devcreek_transmitter.rb +5 -4
- data/lib/time/conversions/timeconversions.rb +13 -0
- data/lib/time/time.rb +11 -0
- data/test/load_devcreek_for_specs.rb +1 -1
- data/test/testcore_spec.rb +1 -1
- data/test/testresult_spec.rb +1 -1
- data/test/testrspecadapter_spec.rb +76 -0
- data/test/testsuite_spec.rb +2 -2
- data/test/testtestunitadapter_spec.rb +80 -0
- data/test/testtimeconversions_spec.rb +31 -0
- data/test/testtransmitter_spec.rb +6 -8
- metadata +10 -3
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -4,17 +4,24 @@ README.txt
|
|
4
4
|
Rakefile
|
5
5
|
lib/devcreek.rb
|
6
6
|
lib/devcreek_core.rb
|
7
|
+
lib/devcreek_logger.rb
|
8
|
+
lib/devcreek_metriccollector.rb
|
7
9
|
lib/devcreek_record_template.rb
|
8
10
|
lib/devcreek_specreporter.rb
|
9
11
|
lib/devcreek_testresult.rb
|
10
12
|
lib/devcreek_testrunnermediator.rb
|
11
13
|
lib/devcreek_testsuite.rb
|
12
14
|
lib/devcreek_transmitter.rb
|
15
|
+
lib/time/conversions/timeconversions.rb
|
16
|
+
lib/time/time.rb
|
13
17
|
test/load_devcreek.rb
|
14
18
|
test/load_devcreek_for_specs.rb
|
15
19
|
test/test_fiction_testunit.rb
|
16
|
-
test/testfiction_spec.rb
|
17
20
|
test/testcore_spec.rb
|
21
|
+
test/testfiction_spec.rb
|
18
22
|
test/testresult_spec.rb
|
23
|
+
test/testrspecadapter_spec.rb
|
19
24
|
test/testsuite_spec.rb
|
25
|
+
test/testtestunitadapter_spec.rb
|
26
|
+
test/testtimeconversions_spec.rb
|
20
27
|
test/testtransmitter_spec.rb
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ Hoe.new('devcreek', DevCreek::VERSION) do |p|
|
|
14
14
|
p.url = 'http://rubyforge.org/projects/devcreek/'
|
15
15
|
p.summary = 'The DevCreek gem enables programmers to collect and transmit metrics from their Ruby test framework to a DevCreek server.'
|
16
16
|
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
17
|
-
p.changes = p.paragraphs_of('History.txt', 0..
|
17
|
+
p.changes = p.paragraphs_of('History.txt', 0..20).join("\n\n")
|
18
18
|
p.extra_deps << ["uuidtools", ">= 1.0.1"]
|
19
19
|
end
|
20
20
|
|
data/lib/devcreek.rb
CHANGED
@@ -5,15 +5,13 @@
|
|
5
5
|
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
6
|
|
7
7
|
require 'logger'
|
8
|
+
require 'time/time.rb'
|
8
9
|
require 'devcreek_testrunnermediator.rb' #for test/unit library
|
9
10
|
begin
|
10
11
|
require 'devcreek_specreporter.rb' #for rspec library
|
11
12
|
rescue Gem::LoadError
|
12
13
|
end
|
13
14
|
|
14
|
-
$DEV_CREEK_LOG = Logger.new($stderr)
|
15
|
-
$DEV_CREEK_LOG.level = Logger::INFO
|
16
|
-
|
17
15
|
module DevCreek
|
18
|
-
VERSION = "0.
|
16
|
+
VERSION = "0.5"
|
19
17
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# devcreek_logger.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
|
+
|
7
|
+
require 'logger'
|
8
|
+
|
9
|
+
module DevCreek
|
10
|
+
module Log
|
11
|
+
DEV_CREEK_LOG = Logger.new($stderr)
|
12
|
+
DEV_CREEK_LOG.level = Logger::INFO
|
13
|
+
def logger
|
14
|
+
return DEV_CREEK_LOG
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# devcreek_metriccollector.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
|
+
|
7
|
+
require 'devcreek_testresult'
|
8
|
+
require 'devcreek_testsuite'
|
9
|
+
require 'devcreek_transmitter'
|
10
|
+
require 'devcreek_core'
|
11
|
+
require 'devcreek_logger'
|
12
|
+
require 'rubygems'
|
13
|
+
require 'uuidtools'
|
14
|
+
require 'singleton'
|
15
|
+
|
16
|
+
module DevCreek
|
17
|
+
class MetricCollector
|
18
|
+
include DevCreek::Log
|
19
|
+
def start(framework)
|
20
|
+
logger.debug "Started collecting metrics from #{framework} framework"
|
21
|
+
@framework = framework
|
22
|
+
@dev_creek_test_suite = DevCreek::TestSuite.new(framework)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_started(test_id, test_name, test_class)
|
26
|
+
logger.debug "#{@framework} test_started: #{test_id}"
|
27
|
+
@dev_creek_test_suite.test_results[test_id] = DevCreek::TestResult.new(test_name, test_class)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_finished(test_id)
|
31
|
+
logger.debug "#{@framework} test_finished: #{test_id}"
|
32
|
+
@dev_creek_test_suite.test_results[test_id].has_finished
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_failed(test_id, due_to_a_failure)
|
36
|
+
logger.debug "#{@framework} test_failed: #{test_id}"
|
37
|
+
|
38
|
+
if due_to_a_failure
|
39
|
+
@dev_creek_test_suite.test_results[test_id].has_a_failure
|
40
|
+
else
|
41
|
+
@dev_creek_test_suite.test_results[test_id].has_an_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def end
|
46
|
+
@dev_creek_test_suite.has_finished
|
47
|
+
if @dev_creek_test_suite.has_test_results?
|
48
|
+
payload = @dev_creek_test_suite.to_xml(UUID.timestamp_create().to_s)
|
49
|
+
logger.debug "Submitting body: \n #{payload}"
|
50
|
+
|
51
|
+
if DevCreek::Core.instance().enabled != false
|
52
|
+
logger.info "Attempting DevCreek transmission..."
|
53
|
+
response = DevCreek::Transmitter.submit(payload)
|
54
|
+
case response
|
55
|
+
when Net::HTTPSuccess
|
56
|
+
logger.info "...transmission successful."
|
57
|
+
else
|
58
|
+
logger.error "...failure transmiting #{@dev_creek_test_suite.framework} results to DevCreek - HTTPResponse with Code # #{response.code}, HTTPResponse message \"#{response.message}\""
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class TestUnitAdapter < MetricCollector
|
66
|
+
include Singleton
|
67
|
+
|
68
|
+
@@dev_creek_reg = /([\w]*)\(([\w]*)\)/
|
69
|
+
|
70
|
+
def start
|
71
|
+
super "Test::Unit"
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_started(name)
|
75
|
+
super(name, name.match(@@dev_creek_reg)[1], name.match(@@dev_creek_reg)[2])
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
class RSpecAdapter < MetricCollector
|
81
|
+
include Singleton
|
82
|
+
|
83
|
+
def start
|
84
|
+
super "RSpec"
|
85
|
+
end
|
86
|
+
|
87
|
+
def example_started(example, behaviour)
|
88
|
+
test_started("#{behaviour}_#{example}", example, behaviour)
|
89
|
+
end
|
90
|
+
|
91
|
+
def example_finished(example, behaviour)
|
92
|
+
test_finished("#{behaviour}_#{example}")
|
93
|
+
end
|
94
|
+
|
95
|
+
def example_failed(example, behaviour, due_to_a_failure)
|
96
|
+
test_failed("#{behaviour}_#{example}", due_to_a_failure)
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
@@ -11,7 +11,7 @@ module DevCreek
|
|
11
11
|
<core.principal><%= DevCreek::Core.instance.principal %></core.principal>
|
12
12
|
<core.project><%= DevCreek::Core.instance.project %></core.project>
|
13
13
|
<core.sessionId><%= session_id %></core.sessionId>
|
14
|
-
<core.timeStamp><%= start.localtime.
|
14
|
+
<core.timeStamp><%= start.localtime.to_millis %></core.timeStamp>
|
15
15
|
<core.timeZoneOffset><%= start.localtime.gmt_offset * 1000 %></core.timeZoneOffset>
|
16
16
|
<core.type>unittest.TestRunStarted</core.type>
|
17
17
|
<unittest.testCount><%= run_count %></unittest.testCount>
|
@@ -24,7 +24,7 @@ module DevCreek
|
|
24
24
|
<core.principal><%= DevCreek::Core.instance.principal %></core.principal>
|
25
25
|
<core.project><%= DevCreek::Core.instance.project %></core.project>
|
26
26
|
<core.sessionId><%= session_id %></core.sessionId>
|
27
|
-
<core.timeStamp><%= test_result.start.localtime.
|
27
|
+
<core.timeStamp><%= test_result.start.localtime.to_millis %></core.timeStamp>
|
28
28
|
<core.timeZoneOffset><%= test_result.start.localtime.gmt_offset * 1000 %></core.timeZoneOffset>
|
29
29
|
<core.type>unittest.TestStarted</core.type>
|
30
30
|
<unittest.testClass><%= test_result.test_class %></unittest.testClass>
|
@@ -37,7 +37,7 @@ module DevCreek
|
|
37
37
|
<core.principal><%= DevCreek::Core.instance.principal %></core.principal>
|
38
38
|
<core.project><%= DevCreek::Core.instance.project %></core.project>
|
39
39
|
<core.sessionId><%= session_id %></core.sessionId>
|
40
|
-
<core.timeStamp><%= test_result.finish.localtime.
|
40
|
+
<core.timeStamp><%= test_result.finish.localtime.to_millis %></core.timeStamp>
|
41
41
|
<core.timeZoneOffset><%= test_result.finish.localtime.gmt_offset * 1000 %></core.timeZoneOffset>
|
42
42
|
<core.type>unittest.TestEnded</core.type>
|
43
43
|
<unittest.testClass><%= test_result.test_class %></unittest.testClass>
|
@@ -53,7 +53,7 @@ module DevCreek
|
|
53
53
|
<core.principal><%= DevCreek::Core.instance.principal %></core.principal>
|
54
54
|
<core.project><%= DevCreek::Core.instance.project %></core.project>
|
55
55
|
<core.sessionId><%= session_id %></core.sessionId>
|
56
|
-
<core.timeStamp><%= finish.localtime.
|
56
|
+
<core.timeStamp><%= finish.localtime.to_millis %></core.timeStamp>
|
57
57
|
<core.timeZoneOffset><%= finish.localtime.gmt_offset * 1000 %></core.timeZoneOffset>
|
58
58
|
<core.type>unittest.TestRunEnded</core.type>
|
59
59
|
<unittest.errorTotal><%= error_count %></unittest.errorTotal>
|
@@ -4,12 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
6
|
|
7
|
-
require '
|
8
|
-
require 'devcreek_testsuite'
|
9
|
-
require 'devcreek_transmitter'
|
10
|
-
require 'devcreek_core'
|
11
|
-
require 'rubygems'
|
12
|
-
require 'uuidtools'
|
7
|
+
require 'devcreek_metriccollector'
|
13
8
|
require 'spec/runner/reporter'
|
14
9
|
|
15
10
|
class Spec::Runner::Reporter
|
@@ -18,75 +13,34 @@ class Spec::Runner::Reporter
|
|
18
13
|
alias_method :old_example_finished, :example_finished
|
19
14
|
alias_method :old_example_failed, :example_failed
|
20
15
|
alias_method :old_end, :end
|
21
|
-
|
16
|
+
|
22
17
|
def start(*args)
|
23
18
|
result = old_start(*args)
|
24
|
-
|
25
|
-
$DEV_CREEK_LOG.debug "rspec started"
|
26
|
-
@dev_creek_test_suite = DevCreek::TestSuite.new("RSpec")
|
27
|
-
|
19
|
+
DevCreek::RSpecAdapter.instance().start
|
28
20
|
return result
|
29
21
|
end
|
30
22
|
|
31
23
|
def example_started(*args)
|
32
24
|
result = old_example_started(*args)
|
33
|
-
|
34
|
-
behaviour = @example_groups.last.description
|
35
|
-
example = args[0].description
|
36
|
-
$DEV_CREEK_LOG.debug "Spec::Runner.example_started: #{behaviour}_#{example}"
|
37
|
-
@dev_creek_test_suite.test_results["#{behaviour}_#{example}"] = DevCreek::TestResult.new(example, behaviour)
|
38
|
-
|
25
|
+
DevCreek::RSpecAdapter.instance().example_started(args[0].description, @example_groups.last.description)
|
39
26
|
return result
|
40
27
|
end
|
41
28
|
|
42
29
|
def example_finished(*args)
|
43
30
|
result = old_example_finished(*args)
|
44
|
-
|
45
|
-
behaviour = @example_groups.last.description
|
46
|
-
example = args[0].description
|
47
|
-
$DEV_CREEK_LOG.debug "Spec::Runner.example_finished: #{behaviour}_#{example}"
|
48
|
-
@dev_creek_test_suite.test_results["#{behaviour}_#{example}"].has_finished
|
49
|
-
|
31
|
+
DevCreek::RSpecAdapter.instance().example_finished(args[0].description, @example_groups.last.description)
|
50
32
|
return result
|
51
33
|
end
|
52
34
|
|
53
35
|
def example_failed(*args)
|
54
36
|
result = old_example_failed(*args)
|
55
|
-
|
56
|
-
behaviour = @example_groups.last.description
|
57
|
-
example = args[0].description
|
58
|
-
$DEV_CREEK_LOG.debug "Spec::Runner.example_failed: #{behaviour}_#{example}"
|
59
|
-
|
60
|
-
dc_test_result = @dev_creek_test_suite.test_results["#{behaviour}_#{example}"]
|
61
|
-
if @failures.last.expectation_not_met?
|
62
|
-
dc_test_result.has_a_failure
|
63
|
-
else
|
64
|
-
dc_test_result.has_an_error
|
65
|
-
end
|
66
|
-
|
37
|
+
DevCreek::RSpecAdapter.instance().example_failed(args[0].description, @example_groups.last.description, @failures.last.expectation_not_met?)
|
67
38
|
return result
|
68
39
|
end
|
69
40
|
|
70
41
|
def end(*args)
|
71
42
|
result = old_end(*args)
|
72
|
-
|
73
|
-
if @dev_creek_test_suite.has_test_results?
|
74
|
-
session_id = UUID.timestamp_create().to_s
|
75
|
-
xml_data = @dev_creek_test_suite.to_xml(session_id)
|
76
|
-
$DEV_CREEK_LOG.debug "Submitting body: \n #{xml_data}"
|
77
|
-
|
78
|
-
if DevCreek::Core.instance().enabled != false
|
79
|
-
$DEV_CREEK_LOG.info "Attempting DevCreek transmission..."
|
80
|
-
response = DevCreek::Transmitter.submit(session_id, xml_data)
|
81
|
-
case response
|
82
|
-
when Net::HTTPSuccess
|
83
|
-
$DEV_CREEK_LOG.info "...transmission successful."
|
84
|
-
else
|
85
|
-
$DEV_CREEK_LOG.error "...failure transmiting TestUnit results to DevCreek - HTTPResponse with Code # #{response.code}, HTTPResponse message \"#{response.message}\""
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
43
|
+
DevCreek::RSpecAdapter.instance().end
|
90
44
|
return result
|
91
45
|
end
|
92
46
|
|
@@ -4,13 +4,8 @@
|
|
4
4
|
#
|
5
5
|
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
6
|
|
7
|
-
require 'devcreek_testresult'
|
8
|
-
require 'devcreek_testsuite'
|
9
|
-
require 'devcreek_transmitter'
|
10
|
-
require 'devcreek_core'
|
11
|
-
require 'rubygems'
|
12
|
-
require 'uuidtools'
|
13
7
|
require 'test/unit/ui/testrunnermediator'
|
8
|
+
require 'devcreek_metriccollector'
|
14
9
|
|
15
10
|
class Test::Unit::UI::TestRunnerMediator
|
16
11
|
alias_method :old_initialize, :initialize
|
@@ -18,54 +13,24 @@ class Test::Unit::UI::TestRunnerMediator
|
|
18
13
|
def initialize(*args)
|
19
14
|
result = old_initialize(*args)
|
20
15
|
|
21
|
-
#DevCreek Modifications
|
22
|
-
@@dev_creek_test_suite = nil
|
23
|
-
@@dev_creek_reg = /([\w]*)\(([\w]*)\)/
|
24
|
-
|
25
16
|
add_listener(Test::Unit::UI::TestRunnerMediator::STARTED) do |test_result|
|
26
|
-
|
27
|
-
@@dev_creek_test_suite = DevCreek::TestSuite.new("Test::Unit")
|
17
|
+
DevCreek::TestUnitAdapter.instance().start
|
28
18
|
end
|
29
19
|
|
30
20
|
add_listener(Test::Unit::TestCase::STARTED) do |name|
|
31
|
-
|
32
|
-
test_name = name.match(@@dev_creek_reg)[1]
|
33
|
-
test_class = name.match(@@dev_creek_reg)[2]
|
34
|
-
@@dev_creek_test_suite.test_results[name] = DevCreek::TestResult.new(test_name, test_class)
|
21
|
+
DevCreek::TestUnitAdapter.instance().test_started(name)
|
35
22
|
end
|
36
23
|
|
37
24
|
add_listener(Test::Unit::TestResult::FAULT) do |fault|
|
38
|
-
|
39
|
-
dc_test_result = @@dev_creek_test_suite.test_results[fault.test_name]
|
40
|
-
if fault.instance_of? Test::Unit::Failure
|
41
|
-
dc_test_result.has_a_failure
|
42
|
-
else
|
43
|
-
dc_test_result.has_an_error
|
44
|
-
end
|
25
|
+
DevCreek::TestUnitAdapter.instance().test_failed(fault.test_name, (fault.instance_of? Test::Unit::Failure))
|
45
26
|
end
|
46
27
|
|
47
|
-
add_listener(Test::Unit::TestCase::FINISHED) do |
|
48
|
-
|
49
|
-
@@dev_creek_test_suite.test_results[test_name].has_finished
|
28
|
+
add_listener(Test::Unit::TestCase::FINISHED) do |name|
|
29
|
+
DevCreek::TestUnitAdapter.instance().test_finished(name)
|
50
30
|
end
|
51
31
|
|
52
32
|
add_listener(Test::Unit::UI::TestRunnerMediator::FINISHED) do |elapsed_time|
|
53
|
-
|
54
|
-
if @@dev_creek_test_suite.has_test_results?
|
55
|
-
session_id = UUID.timestamp_create().to_s
|
56
|
-
xml_data = @@dev_creek_test_suite.to_xml(session_id)
|
57
|
-
$DEV_CREEK_LOG.debug "Submitting body: \n #{xml_data}"
|
58
|
-
if DevCreek::Core.instance().enabled != false
|
59
|
-
$DEV_CREEK_LOG.info "Attempting DevCreek transmission..."
|
60
|
-
response = DevCreek::Transmitter.submit(session_id, xml_data)
|
61
|
-
case response
|
62
|
-
when Net::HTTPSuccess
|
63
|
-
$DEV_CREEK_LOG.info "...transmission successful."
|
64
|
-
else
|
65
|
-
$DEV_CREEK_LOG.error "...failure transmiting TestUnit results to DevCreek - HTTPResponse with Code # #{response.code}, HTTPResponse message \"#{response.message}\""
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
33
|
+
DevCreek::TestUnitAdapter.instance().end
|
69
34
|
end
|
70
35
|
|
71
36
|
return result
|
data/lib/devcreek_transmitter.rb
CHANGED
@@ -13,9 +13,9 @@ module DevCreek
|
|
13
13
|
|
14
14
|
SUBMIT_URL = "https://devcreek.com/submitData2/"
|
15
15
|
|
16
|
-
def Transmitter.submit(
|
16
|
+
def Transmitter.submit(the_payload)
|
17
17
|
|
18
|
-
raise Exception.new("Invalid argument:
|
18
|
+
raise Exception.new("Invalid argument: payload cannot be nil") if the_payload.nil?
|
19
19
|
raise Exception.new("Core data not initialized") if DevCreek::Core.instance().project.nil? or
|
20
20
|
DevCreek::Core.instance().user.nil? or
|
21
21
|
DevCreek::Core.instance().password.nil?
|
@@ -23,16 +23,17 @@ module DevCreek
|
|
23
23
|
url = URI.parse("#{SUBMIT_URL}#{DevCreek::Core.instance().project}")
|
24
24
|
response = nil
|
25
25
|
Net::HTTP.start(url.host) do |http|
|
26
|
-
|
26
|
+
http.head(url.request_uri)
|
27
27
|
req = Net::HTTP::Post.new(url.path)
|
28
28
|
|
29
29
|
#gzip the request_data
|
30
30
|
strio = StringIO.new('', 'w')
|
31
31
|
gz = Zlib::GzipWriter.new(strio)
|
32
|
-
gz.write
|
32
|
+
gz.write the_payload
|
33
33
|
gz.close
|
34
34
|
req.body= strio.string
|
35
35
|
req.add_field('Content-Encoding', 'gzip')
|
36
|
+
req.add_field('Content-Type', 'application/xml')
|
36
37
|
req.basic_auth(DevCreek::Core.instance().user, DevCreek::Core.instance().password)
|
37
38
|
response = http.request(req)
|
38
39
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# timeconversions.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
|
+
|
7
|
+
module DevCreek
|
8
|
+
module TimeConversions
|
9
|
+
def to_millis
|
10
|
+
return (self.to_i * 1000) + self.usec
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/time/time.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# devcreek_time.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
|
+
require 'time'
|
7
|
+
require File.dirname(__FILE__) + '/conversions/timeconversions.rb'
|
8
|
+
|
9
|
+
class Time#:nodoc:
|
10
|
+
include DevCreek::TimeConversions
|
11
|
+
end
|
data/test/testcore_spec.rb
CHANGED
data/test/testresult_spec.rb
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
# testsuite_spec.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
|
+
|
7
|
+
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
8
|
+
require 'devcreek_metriccollector'
|
9
|
+
require 'rexml/document'
|
10
|
+
|
11
|
+
describe DevCreek::RSpecAdapter do
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
@adapter = DevCreek::RSpecAdapter.instance
|
15
|
+
@adapter.start
|
16
|
+
def @adapter.test_suite
|
17
|
+
return self.instance_variable_get(:@dev_creek_test_suite)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
@adapter = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be initialized with a test_suite when start is invoked" do
|
26
|
+
@adapter.test_suite.should_not be_nil
|
27
|
+
@adapter.test_suite.should be_an_instance_of(DevCreek::TestSuite)
|
28
|
+
@adapter.test_suite.framework.should eql('RSpec')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should record the correct info when an example is started" do
|
32
|
+
example = 'an example'
|
33
|
+
behaviour = 'a behaviour'
|
34
|
+
@adapter.example_started example, behaviour
|
35
|
+
@adapter.test_suite.test_results.size.should eql(1)
|
36
|
+
@adapter.test_suite.test_results.values[0].should be_an_instance_of(DevCreek::TestResult)
|
37
|
+
@adapter.test_suite.test_results.values[0].test_name.should eql(example)
|
38
|
+
@adapter.test_suite.test_results.values[0].test_class.should eql(behaviour)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should record the correct info when an example is finished" do
|
42
|
+
example = 'an example'
|
43
|
+
behaviour = 'a behaviour'
|
44
|
+
@adapter.example_started 'othe_example', behaviour
|
45
|
+
@adapter.example_started example, behaviour
|
46
|
+
@adapter.test_suite.test_results.values[0].finish.should be_nil
|
47
|
+
@adapter.test_suite.test_results.values[1].finish.should be_nil
|
48
|
+
@adapter.example_finished example, behaviour
|
49
|
+
@adapter.test_suite.test_results.values[0].finish.should be_nil
|
50
|
+
@adapter.test_suite.test_results.values[1].finish.should_not be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should record the correct info when an example fails" do
|
54
|
+
example = 'an example'
|
55
|
+
behaviour = 'a behaviour'
|
56
|
+
|
57
|
+
@adapter.example_started example, behaviour
|
58
|
+
@adapter.example_finished example, behaviour
|
59
|
+
|
60
|
+
due_to_a_failure = true
|
61
|
+
@adapter.example_failed example, behaviour, due_to_a_failure
|
62
|
+
@adapter.test_suite.test_results.values[0].status.should eql(DevCreek::TestResult::FAILURE)
|
63
|
+
|
64
|
+
due_to_an_error = false
|
65
|
+
@adapter.example_failed example, behaviour, due_to_an_error
|
66
|
+
@adapter.test_suite.test_results.values[0].status.should eql(DevCreek::TestResult::ERROR)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should record the fact that is has finished when end is invoked" do
|
70
|
+
@adapter.test_suite.finish.should be_nil
|
71
|
+
@adapter.end
|
72
|
+
@adapter.test_suite.finish.should_not be_nil
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
data/test/testsuite_spec.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
6
|
|
7
7
|
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
8
|
-
require '
|
8
|
+
require 'devcreek_testsuite.rb'
|
9
9
|
require 'rexml/document'
|
10
10
|
|
11
11
|
describe DevCreek::TestSuite do
|
@@ -94,7 +94,7 @@ describe DevCreek::TestSuite do
|
|
94
94
|
doc.get_elements('//core.principal').each {|tag| tag.text.should eql("Skinnard") }
|
95
95
|
doc.get_elements('//core.project').each {|tag| tag.text.should eql("Foo") }
|
96
96
|
doc.get_elements('//core.sessionId').each {|tag| tag.text.should eql("unique") }
|
97
|
-
doc.get_elements('//core.timeStamp')[0].text.to_i.should eql(@suite.start.
|
97
|
+
doc.get_elements('//core.timeStamp')[0].text.to_i.should eql(@suite.start.to_millis)
|
98
98
|
|
99
99
|
|
100
100
|
doc.get_elements('//unittest.testCount')[0].text.should eql("1")
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# testsuite_spec.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
|
+
|
7
|
+
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
8
|
+
require 'devcreek_metriccollector.rb'
|
9
|
+
require 'rexml/document'
|
10
|
+
|
11
|
+
describe DevCreek::TestUnitAdapter do
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
@adapter = DevCreek::TestUnitAdapter.instance
|
15
|
+
@adapter.start
|
16
|
+
def @adapter.test_suite
|
17
|
+
return self.instance_variable_get(:@dev_creek_test_suite)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
@adapter = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be initialized with a test_suite when start is invoked" do
|
26
|
+
@adapter.test_suite.should_not be_nil
|
27
|
+
@adapter.test_suite.should be_an_instance_of(DevCreek::TestSuite)
|
28
|
+
@adapter.test_suite.framework.should eql('Test::Unit')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should record the correct info when a test is started" do
|
32
|
+
test_name = 'test_name'
|
33
|
+
test_class = 'test_class'
|
34
|
+
test = "#{test_name}(#{test_class})"
|
35
|
+
@adapter.test_started test
|
36
|
+
@adapter.test_suite.test_results.size.should eql(1)
|
37
|
+
@adapter.test_suite.test_results.values[0].should be_an_instance_of(DevCreek::TestResult)
|
38
|
+
@adapter.test_suite.test_results.values[0].test_name.should eql(test_name)
|
39
|
+
@adapter.test_suite.test_results.values[0].test_class.should eql(test_class)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should record the correct info when a test is finished" do
|
43
|
+
test_name = 'test_name'
|
44
|
+
test_class = 'test_class'
|
45
|
+
test = "#{test_name}(#{test_class})"
|
46
|
+
other_test = "otherTestName(#{test_class})"
|
47
|
+
@adapter.test_started other_test
|
48
|
+
@adapter.test_started test
|
49
|
+
@adapter.test_suite.test_results[test].finish.should be_nil
|
50
|
+
@adapter.test_suite.test_results[other_test].finish.should be_nil
|
51
|
+
@adapter.test_finished test
|
52
|
+
@adapter.test_suite.test_results[test].finish.should_not be_nil
|
53
|
+
@adapter.test_suite.test_results[other_test].finish.should be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should record the correct info when an test fails" do
|
57
|
+
test_name = 'test_name'
|
58
|
+
test_class = 'test_class'
|
59
|
+
test = "#{test_name}(#{test_class})"
|
60
|
+
|
61
|
+
@adapter.test_started test
|
62
|
+
@adapter.test_finished test
|
63
|
+
|
64
|
+
due_to_a_failure = true
|
65
|
+
@adapter.test_failed test, due_to_a_failure
|
66
|
+
@adapter.test_suite.test_results.values[0].status.should eql(DevCreek::TestResult::FAILURE)
|
67
|
+
|
68
|
+
due_to_an_error = false
|
69
|
+
@adapter.test_failed test, due_to_an_error
|
70
|
+
@adapter.test_suite.test_results.values[0].status.should eql(DevCreek::TestResult::ERROR)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should record the fact that is has finished when end is invoked" do
|
74
|
+
@adapter.test_suite.finish.should be_nil
|
75
|
+
@adapter.end
|
76
|
+
@adapter.test_suite.finish.should_not be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# testsuite_spec.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file README.txt in the distribution
|
6
|
+
|
7
|
+
require 'fileutils'
|
8
|
+
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
9
|
+
|
10
|
+
require 'time/time.rb'
|
11
|
+
|
12
|
+
describe "The to_millis method on the class", Time do
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
@time = Time.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should exist" do
|
19
|
+
@time.should respond_to(:to_millis)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return an Integer value" do
|
23
|
+
@time.to_millis.should_not be_nil
|
24
|
+
@time.to_millis.should be_a_kind_of(Integer)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return the correct number of milliseconds " do
|
28
|
+
@time.to_millis.should eql((@time.to_i * 1000) + @time.usec)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -17,23 +17,21 @@ describe DevCreek::Transmitter do
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "submit method should raise an error if
|
21
|
-
lambda{DevCreek::Transmitter.submit(nil
|
22
|
-
lambda{DevCreek::Transmitter.submit('a_session_id', nil)}.should raise_error(Exception, "Invalid argument: session_id and xml_data cannot be nil")
|
23
|
-
lambda{DevCreek::Transmitter.submit(nil, '<somexml/>')}.should raise_error(Exception, "Invalid argument: session_id and xml_data cannot be nil")
|
20
|
+
it "submit method should raise an error if the payload is nil" do
|
21
|
+
lambda{DevCreek::Transmitter.submit(nil)}.should raise_error(Exception, "Invalid argument: payload cannot be nil")
|
24
22
|
end
|
25
23
|
|
26
24
|
it "submit method should raise an error if the Core data has not been initialized" do
|
27
|
-
lambda{DevCreek::Transmitter.submit('
|
25
|
+
lambda{DevCreek::Transmitter.submit('<somexml/>')}.should raise_error(Exception, "Core data not initialized")
|
28
26
|
|
29
27
|
DevCreek::Core.instance().project= 'FooProject'
|
30
|
-
lambda{DevCreek::Transmitter.submit('
|
28
|
+
lambda{DevCreek::Transmitter.submit('<somexml/>')}.should raise_error(Exception, "Core data not initialized")
|
31
29
|
|
32
30
|
DevCreek::Core.instance().user= 'Fred Flintstone'
|
33
|
-
lambda{DevCreek::Transmitter.submit('
|
31
|
+
lambda{DevCreek::Transmitter.submit('<somexml/>')}.should raise_error(Exception, "Core data not initialized")
|
34
32
|
|
35
33
|
DevCreek::Core.instance().password= 'Foobar'
|
36
|
-
lambda{DevCreek::Transmitter.submit('
|
34
|
+
lambda{DevCreek::Transmitter.submit('<somexml/>')}.should_not raise_error(Exception, "Core data not initialized")
|
37
35
|
end
|
38
36
|
|
39
37
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: devcreek
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2008-01-
|
6
|
+
version: "0.5"
|
7
|
+
date: 2008-01-20 00:00:00 -05:00
|
8
8
|
summary: The DevCreek gem enables programmers to collect and transmit metrics from their Ruby test framework to a DevCreek server.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -35,19 +35,26 @@ files:
|
|
35
35
|
- Rakefile
|
36
36
|
- lib/devcreek.rb
|
37
37
|
- lib/devcreek_core.rb
|
38
|
+
- lib/devcreek_logger.rb
|
39
|
+
- lib/devcreek_metriccollector.rb
|
38
40
|
- lib/devcreek_record_template.rb
|
39
41
|
- lib/devcreek_specreporter.rb
|
40
42
|
- lib/devcreek_testresult.rb
|
41
43
|
- lib/devcreek_testrunnermediator.rb
|
42
44
|
- lib/devcreek_testsuite.rb
|
43
45
|
- lib/devcreek_transmitter.rb
|
46
|
+
- lib/time/conversions/timeconversions.rb
|
47
|
+
- lib/time/time.rb
|
44
48
|
- test/load_devcreek.rb
|
45
49
|
- test/load_devcreek_for_specs.rb
|
46
50
|
- test/test_fiction_testunit.rb
|
47
|
-
- test/testfiction_spec.rb
|
48
51
|
- test/testcore_spec.rb
|
52
|
+
- test/testfiction_spec.rb
|
49
53
|
- test/testresult_spec.rb
|
54
|
+
- test/testrspecadapter_spec.rb
|
50
55
|
- test/testsuite_spec.rb
|
56
|
+
- test/testtestunitadapter_spec.rb
|
57
|
+
- test/testtimeconversions_spec.rb
|
51
58
|
- test/testtransmitter_spec.rb
|
52
59
|
test_files:
|
53
60
|
- test/test_fiction_testunit.rb
|