devcreek 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +504 -0
- data/History.txt +4 -0
- data/Manifest.txt +17 -0
- data/README.txt +598 -0
- data/lib/devcreek.rb +10 -0
- data/lib/devcreek_core.rb +28 -0
- data/lib/devcreek_record_template.rb +67 -0
- data/lib/devcreek_testresult.rb +36 -0
- data/lib/devcreek_testrunnermediator.rb +80 -0
- data/lib/devcreek_testsuite.rb +58 -0
- data/lib/devcreek_transmitter.rb +35 -0
- data/lib/digest_auth.rb +37 -0
- data/test/test_fiction.rb +45 -0
- data/test/testcore_spec.rb +70 -0
- data/test/testresult_spec.rb +74 -0
- data/test/testsuite_spec.rb +152 -0
- data/test/testtransmitter_spec.rb +39 -0
- metadata +82 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
# testresult_spec.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
|
+
|
7
|
+
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
8
|
+
require 'devcreek'
|
9
|
+
|
10
|
+
describe DevCreek::TestResult do
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
@test_result = DevCreek::TestResult.new("some_test", "SomeClass")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be initialized with a start time" do
|
17
|
+
@test_result.start.should_not be_nil
|
18
|
+
@test_result.start.should be_an_instance_of(Time)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be initialized with a test name" do
|
22
|
+
@test_result.test_name.should_not be_nil
|
23
|
+
@test_result.test_name.should eql("some_test")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be initialized with a test class" do
|
27
|
+
@test_result.test_class.should_not be_nil
|
28
|
+
@test_result.test_class.should eql("SomeClass")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should not be possible to change the name or start time" do
|
32
|
+
lambda{@test_result.name = "foo"}.should raise_error(NoMethodError)
|
33
|
+
lambda{@test_result.start = Time.now}.should raise_error(NoMethodError)
|
34
|
+
lambda{@test_result.has_finished}.should_not raise_error(NoMethodError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not be initialized with a finish time" do
|
38
|
+
@test_result.finish.should be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have a finish time when I set it" do
|
42
|
+
@test_result.has_finished
|
43
|
+
@test_result.finish.should_not be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should raise an error if I set the finish time more than once" do
|
47
|
+
lambda{@test_result.has_finished}.should_not raise_error
|
48
|
+
lambda{@test_result.has_finished}.should raise_error(ArgumentError, "The finish time cannot be set twice")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return nil for the elapsed time if the finish time is nil" do
|
52
|
+
@test_result.elapsed_time.should be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should calculate the elapsed time if the finish time is set" do
|
56
|
+
@test_result.has_finished
|
57
|
+
@test_result.elapsed_time.should eql(@test_result.finish - @test_result.start)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have a default status of OK" do
|
61
|
+
@test_result.status.should eql(DevCreek::TestResult::OK)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should remember a failure" do
|
65
|
+
@test_result.has_a_failure
|
66
|
+
@test_result.status.should eql(DevCreek::TestResult::FAILURE)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should remember an error" do
|
70
|
+
@test_result.has_an_error
|
71
|
+
@test_result.status.should eql(DevCreek::TestResult::ERROR)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# testsuite_spec.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
|
+
|
7
|
+
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
8
|
+
require 'devcreek'
|
9
|
+
require 'rexml/document'
|
10
|
+
|
11
|
+
describe DevCreek::TestSuite do
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
@suite = DevCreek::TestSuite.new("TestUnit")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be initialized with framework" do
|
18
|
+
@suite.framework.should eql("TestUnit")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should be initialized with an elapsed time of 0.0" do
|
22
|
+
@suite.elapsed_time.should eql(0.0)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be initialized with a hash called test_results" do
|
26
|
+
@suite.test_results.should be_an_instance_of(Hash)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be initialized with 0 test runs" do
|
30
|
+
@suite.run_count.should eql(0)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be initialized with a time stamp" do
|
34
|
+
@suite.start.should_not be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return a run_count that matches the size of the test_results" do
|
38
|
+
@suite.test_results['a'] = DevCreek::TestResult.new("a", "SomeClass")
|
39
|
+
@suite.test_results['b'] = DevCreek::TestResult.new("b", "SomeClass")
|
40
|
+
@suite.test_results['c'] = DevCreek::TestResult.new("c", "SomeClass")
|
41
|
+
@suite.run_count.should eql(3)
|
42
|
+
@suite.test_results['d'] = DevCreek::TestResult.new("d", "SomeClass")
|
43
|
+
@suite.run_count.should eql(4)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return a success_count that matches the size of the successful test_results" do
|
47
|
+
@suite.test_results['a'] = DevCreek::TestResult.new("a", "SomeClass")
|
48
|
+
@suite.test_results['b'] = DevCreek::TestResult.new("b", "SomeClass")
|
49
|
+
@suite.test_results['c'] = DevCreek::TestResult.new("c", "SomeClass")
|
50
|
+
@suite.success_count.should eql(3)
|
51
|
+
@suite.failure_count.should eql(0)
|
52
|
+
@suite.error_count.should eql(0)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return a failure_count that matches the size of the failed test_results" do
|
56
|
+
@suite.test_results['a'] = DevCreek::TestResult.new("a", "SomeClass")
|
57
|
+
@suite.test_results['a'].has_a_failure
|
58
|
+
@suite.test_results['b'] = DevCreek::TestResult.new("b", "SomeClass")
|
59
|
+
@suite.test_results['b'].has_a_failure
|
60
|
+
@suite.test_results['c'] = DevCreek::TestResult.new("c", "SomeClass")
|
61
|
+
@suite.test_results['c'].has_a_failure
|
62
|
+
@suite.failure_count.should eql(3)
|
63
|
+
@suite.success_count.should eql(0)
|
64
|
+
@suite.error_count.should eql(0)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should return a error_count that matches the size of the error test_results" do
|
68
|
+
@suite.test_results['a'] = DevCreek::TestResult.new("a", "SomeClass")
|
69
|
+
@suite.test_results['a'].has_an_error
|
70
|
+
@suite.test_results['b'] = DevCreek::TestResult.new("b", "SomeClass")
|
71
|
+
@suite.test_results['b'].has_an_error
|
72
|
+
@suite.test_results['c'] = DevCreek::TestResult.new("c", "SomeClass")
|
73
|
+
@suite.test_results['c'].has_an_error
|
74
|
+
@suite.error_count.should eql(3)
|
75
|
+
@suite.failure_count.should eql(0)
|
76
|
+
@suite.success_count.should eql(0)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should raise an error if I set the finish time more than once" do
|
80
|
+
lambda{@suite.has_finished}.should_not raise_error
|
81
|
+
lambda{@suite.has_finished}.should raise_error(ArgumentError, "The finish time cannot be set twice")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return an xml string with the correct core data" do
|
85
|
+
@suite.test_results['a'] = DevCreek::TestResult.new("a", "SomeClass")
|
86
|
+
@suite.test_results['a'].has_finished
|
87
|
+
@suite.has_finished
|
88
|
+
|
89
|
+
DevCreek::Core.instance().principal = "Skinnard"
|
90
|
+
DevCreek::Core.instance().project= "Foo"
|
91
|
+
|
92
|
+
doc = REXML::Document.new('<records>' + @suite.to_xml('unique') + '</records>')
|
93
|
+
doc.get_elements('//core.principal').each {|tag| tag.text.should eql("Skinnard") }
|
94
|
+
doc.get_elements('//core.principal').each {|tag| tag.text.should eql("Skinnard") }
|
95
|
+
doc.get_elements('//core.project').each {|tag| tag.text.should eql("Foo") }
|
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.localtime.to_i * 1000)
|
98
|
+
|
99
|
+
|
100
|
+
doc.get_elements('//unittest.testCount')[0].text.should eql("1")
|
101
|
+
doc.get_elements('//unittest.testFramework').size.should_not eql(0)
|
102
|
+
doc.get_elements('//unittest.testFramework').each {|tag| tag.text.should eql(@suite.framework) }
|
103
|
+
doc.get_elements('//unittest.testLanguage').each {|tag| tag.text.should eql("ruby") }
|
104
|
+
doc.get_elements('//unittest.testRunLauncher').each {|tag| tag.text.should eql("manual") }
|
105
|
+
|
106
|
+
doc.get_elements('//record').size.should eql(4)
|
107
|
+
doc.get_elements('//unittest.testClass').each {|tag| tag.text.should eql("SomeClass") }
|
108
|
+
doc.get_elements('//core.type')[0].text.should eql("unittest.TestRunStarted")
|
109
|
+
doc.get_elements('//core.type')[1].text.should eql("unittest.TestStarted")
|
110
|
+
doc.get_elements('//core.type')[2].text.should eql("unittest.TestEnded")
|
111
|
+
doc.get_elements('//core.type')[3].text.should eql("unittest.TestRunEnded")
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should return an xml string with the correct test results" do
|
115
|
+
@suite.test_results['test1(SomeClass)'] = DevCreek::TestResult.new("test1", "SomeClass")
|
116
|
+
@suite.test_results['test1(SomeClass)'].has_finished
|
117
|
+
|
118
|
+
@suite.test_results['test2(SomeClass)'] = DevCreek::TestResult.new("test2", "SomeClass")
|
119
|
+
@suite.test_results['test2(SomeClass)'].has_a_failure
|
120
|
+
@suite.test_results['test2(SomeClass)'].has_finished
|
121
|
+
|
122
|
+
@suite.test_results['test1(OtherClass)'] = DevCreek::TestResult.new("test3", "OtherClass")
|
123
|
+
@suite.test_results['test1(OtherClass)'].has_an_error
|
124
|
+
@suite.test_results['test1(OtherClass)'].has_finished
|
125
|
+
@suite.has_finished
|
126
|
+
|
127
|
+
doc = REXML::Document.new('<records>' + @suite.to_xml('unique') + '</records>')
|
128
|
+
doc.get_elements('//record').size.should eql(8)
|
129
|
+
doc.get_elements('//unittest.testCount')[0].text.should eql('3')
|
130
|
+
doc.get_elements('//unittest.errorTotal')[0].text.should eql('1')
|
131
|
+
doc.get_elements('//unittest.failureTotal')[0].text.should eql('1')
|
132
|
+
doc.get_elements('//unittest.successTotal')[0].text.should eql('1')
|
133
|
+
doc.get_elements('//unittest.testClass').size.should eql(6)
|
134
|
+
doc.get_elements('//unittest.testClass')[0].text.should eql('SomeClass')
|
135
|
+
|
136
|
+
doc.get_elements('/records/record[unittest.testName=\'test1\']/unittest.testClass').size.should eql(2)
|
137
|
+
doc.get_elements('/records/record[unittest.testName=\'test1\']/unittest.testClass')[0].text.should eql('SomeClass')
|
138
|
+
doc.get_elements('/records/record[unittest.testName=\'test1\']/unittest.testClass')[1].text.should eql('SomeClass')
|
139
|
+
doc.get_elements('/records/record[unittest.testName=\'test1\']/unittest.testStatus')[0].text.should eql('OK')
|
140
|
+
|
141
|
+
doc.get_elements('/records/record[unittest.testName=\'test2\']/unittest.testClass').size.should eql(2)
|
142
|
+
doc.get_elements('/records/record[unittest.testName=\'test2\']/unittest.testClass')[0].text.should eql('SomeClass')
|
143
|
+
doc.get_elements('/records/record[unittest.testName=\'test2\']/unittest.testClass')[1].text.should eql('SomeClass')
|
144
|
+
doc.get_elements('/records/record[unittest.testName=\'test2\']/unittest.testStatus')[0].text.should eql('FAILURE')
|
145
|
+
|
146
|
+
doc.get_elements('/records/record[unittest.testName=\'test3\']/unittest.testClass').size.should eql(2)
|
147
|
+
doc.get_elements('/records/record[unittest.testName=\'test3\']/unittest.testClass')[0].text.should eql('OtherClass')
|
148
|
+
doc.get_elements('/records/record[unittest.testName=\'test3\']/unittest.testClass')[1].text.should eql('OtherClass')
|
149
|
+
doc.get_elements('/records/record[unittest.testName=\'test3\']/unittest.testStatus')[0].text.should eql('ERROR')
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# testtansmitter_spec.rb
|
2
|
+
#
|
3
|
+
# Copyright Caleb Powell 2007
|
4
|
+
#
|
5
|
+
# Licensed under the LGPL, see the file COPYING in the distribution
|
6
|
+
|
7
|
+
$LOAD_PATH.push(FileUtils::pwd + '/lib')
|
8
|
+
require 'devcreek_transmitter'
|
9
|
+
|
10
|
+
describe DevCreek::Transmitter do
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
DevCreek::Core.instance().load(
|
14
|
+
:user => nil,
|
15
|
+
:password => nil,
|
16
|
+
:project => nil
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "submit method should raise an error if either arguments are invalid" do
|
21
|
+
lambda{DevCreek::Transmitter.submit(nil, nil)}.should raise_error(Exception, "Invalid argument: session_id and xml_data cannot be 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")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "submit method should raise an error if the Core data has not been initialized" do
|
27
|
+
lambda{DevCreek::Transmitter.submit('a_session_id', '<somexml/>')}.should raise_error(Exception, "Core data not initialized")
|
28
|
+
|
29
|
+
DevCreek::Core.instance().project= 'FooProject'
|
30
|
+
lambda{DevCreek::Transmitter.submit('a_session_id', '<somexml/>')}.should raise_error(Exception, "Core data not initialized")
|
31
|
+
|
32
|
+
DevCreek::Core.instance().user= 'Fred Flintstone'
|
33
|
+
lambda{DevCreek::Transmitter.submit('a_session_id', '<somexml/>')}.should raise_error(Exception, "Core data not initialized")
|
34
|
+
|
35
|
+
DevCreek::Core.instance().password= 'Foobar'
|
36
|
+
lambda{DevCreek::Transmitter.submit('a_session_id', '<somexml/>')}.should_not raise_error(Exception, "Core data not initialized")
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: devcreek
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.1"
|
7
|
+
date: 2007-12-06 00:00:00 -05:00
|
8
|
+
summary: The DevCreek gem enables programmers to collect and transmit metrics from their Ruby test framework to a DevCreek server.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: caleb.powell@gmail.com
|
12
|
+
homepage: http://rubyforge.org/projects/devcreek/
|
13
|
+
rubyforge_project: devcreek
|
14
|
+
description: "The DevCreek gem enables programmers to collect and transmit metrics from their Ruby Test::Unit test suites to a DevCreek server. Please visit the DevCreek site (http://devcreek.com/index.html/) for more info. == FEATURES/PROBLEMS: Test::Unit is the currently the only supported framework. Rspec support is on it's way ;-) == SYNOPSIS: The DevCreek Ruby Gem is library that, when loaded, will automatically listen to and collect metrics from your Test::Unit unit tests. All you have to do is load the DevCreek library in your code and give it your DevCreek account info so that it can transmit the metrics to the server. Here is the simplest example of how to load DevCreek: -------- #Load the devcreek gem require 'rubygems' require 'devcreek' #set your account info DevCreek::Core.instance().load_from_yaml(\"#{ENV['HOME']}/.yoursettingsfile.devcreek.yml\") -------- There are two ways to provide DevCreek with your account settings. The first (as shown above) is to point DevCreek to a settings file. The 'enabled' attribute tells devcreek whether or not it should actually transmit the metrics that it collects. The yaml file would like this: -------- user: your_devcreek_username password: your_devcreek_password project: your_devcreek_project enabled: true -------- The other way to provide DevCreek with your settings is via a hash. So, instead of loading a yaml file, you could do this: -------- #Load the devcreek gem require 'rubygems' require 'devcreek' #set your account info DevCreek::Core.instance().load( :user => 'your_devcreek_username', :password => 'your_devcreek_password', :project => 'your_devcreek_project' :enabled => true ) -------- The first method is preferrable because it allows you to keep your account settings outside of your project (and therefore your source control tool). If you only have 1 test file, you can place the code to load devcreek in the test file and your done. However, most projects will have many test files. In this case, you need to make sure that the Ruby interpreter loads devcreek before running the test classes. This can be done via the Ruby '-r' option. For example, assuming your code to load devcreek is in a file called foo.rb, you would run your tests from the command line like this: ruby -r foo.rb test/test_* If you run your tests from a Rakefile, then you need to tell rake to include the -r option when it runs the tests (rake runs it's tests in a separate Ruby process). You can do this pretty easily in your Rakefile, like so; -------- require 'rake/testtask' Rake::TestTask.new('all_tests') do |t| t.ruby_opts = ['-r foo.rb'] t.test_files = ['test/test_*.rb'] end -------- == REQUIREMENTS:"
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Caleb Powell
|
31
|
+
files:
|
32
|
+
- COPYING
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
- lib/devcreek.rb
|
37
|
+
- lib/devcreek_core.rb
|
38
|
+
- lib/devcreek_record_template.rb
|
39
|
+
- lib/devcreek_testresult.rb
|
40
|
+
- lib/devcreek_testrunnermediator.rb
|
41
|
+
- lib/devcreek_testsuite.rb
|
42
|
+
- lib/devcreek_transmitter.rb
|
43
|
+
- lib/digest_auth.rb
|
44
|
+
- test/test_fiction.rb
|
45
|
+
- test/testcore_spec.rb
|
46
|
+
- test/testresult_spec.rb
|
47
|
+
- test/testsuite_spec.rb
|
48
|
+
- test/testtransmitter_spec.rb
|
49
|
+
test_files:
|
50
|
+
- test/test_fiction.rb
|
51
|
+
rdoc_options:
|
52
|
+
- --main
|
53
|
+
- README.txt
|
54
|
+
extra_rdoc_files:
|
55
|
+
- History.txt
|
56
|
+
- Manifest.txt
|
57
|
+
- README.txt
|
58
|
+
executables: []
|
59
|
+
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
dependencies:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: uuidtools
|
67
|
+
version_requirement:
|
68
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.0.1
|
73
|
+
version:
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: hoe
|
76
|
+
version_requirement:
|
77
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.3.0
|
82
|
+
version:
|