baretest 0.1.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +52 -0
- data/MANIFEST.txt +50 -31
- data/README.rdoc +260 -0
- data/bin/baretest +82 -24
- data/doc/baretest.rdoc +98 -0
- data/doc/mocking_stubbing_test_doubles.rdoc +5 -0
- data/doc/quickref.rdoc +261 -0
- data/doc/writing_tests.rdoc +148 -0
- data/examples/test.rake +58 -30
- data/examples/tests/irb_mode/failures.rb +26 -0
- data/examples/tests/mock_developer/test/helper/mocks.rb +0 -0
- data/examples/tests/mock_developer/test/setup.rb +57 -0
- data/examples/tests/mock_developer/test/suite/mock_demo.rb +19 -0
- data/examples/tests/overview/test.rb +89 -0
- data/examples/tests/variations/variations_01.rb +14 -0
- data/examples/tests/variations/variations_02.rb +19 -0
- data/examples/tests/variations/variations_03.rb +19 -0
- data/lib/baretest/assertion/context.rb +20 -0
- data/lib/baretest/assertion/failure.rb +22 -0
- data/lib/baretest/assertion/skip.rb +21 -0
- data/lib/{test → baretest}/assertion/support.rb +174 -39
- data/lib/baretest/assertion.rb +182 -0
- data/lib/baretest/irb_mode.rb +263 -0
- data/lib/{test/assertion/failure.rb → baretest/layout.rb} +6 -5
- data/lib/baretest/mocha.rb +18 -0
- data/lib/baretest/run/cli.rb +104 -0
- data/lib/{test → baretest}/run/errors.rb +12 -7
- data/lib/{test → baretest}/run/minimal.rb +8 -3
- data/lib/baretest/run/profile.rb +151 -0
- data/lib/{test → baretest}/run/spec.rb +10 -4
- data/lib/baretest/run/tap.rb +44 -0
- data/lib/baretest/run/xml.rb +80 -0
- data/lib/{test → baretest}/run.rb +31 -18
- data/lib/baretest/setup.rb +15 -0
- data/lib/baretest/skipped/assertion.rb +20 -0
- data/lib/baretest/skipped/suite.rb +49 -0
- data/lib/baretest/skipped.rb +15 -0
- data/lib/baretest/suite.rb +234 -0
- data/lib/baretest/utilities.rb +43 -0
- data/lib/{test → baretest}/version.rb +12 -3
- data/lib/baretest.rb +112 -0
- data/test/external/bootstraptest.rb +1 -1
- data/test/setup.rb +1 -1
- data/test/{lib/test → suite/lib/baretest}/assertion/support.rb +78 -24
- data/test/suite/lib/baretest/assertion.rb +192 -0
- data/test/{lib/test → suite/lib/baretest}/irb_mode.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/cli.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/errors.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/interactive.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/spec.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/tap.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run/xml.rb +0 -0
- data/test/{lib/test → suite/lib/baretest}/run.rb +63 -61
- data/test/{lib/test → suite/lib/baretest}/suite.rb +77 -54
- data/test/{lib/test.rb → suite/lib/baretest.rb} +37 -37
- metadata +61 -40
- data/README.markdown +0 -229
- data/examples/test.rb +0 -93
- data/lib/test/assertion.rb +0 -117
- data/lib/test/debug.rb +0 -34
- data/lib/test/irb_mode.rb +0 -104
- data/lib/test/run/cli.rb +0 -79
- data/lib/test/run/interactive.rb +0 -60
- data/lib/test/run/tap.rb +0 -32
- data/lib/test/run/xml.rb +0 -56
- data/lib/test/suite.rb +0 -95
- data/lib/test.rb +0 -118
- data/test/lib/test/assertion.rb +0 -142
- data/test/lib/test/debug.rb +0 -63
@@ -6,36 +6,36 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
BareTest.suite "BareTest" do
|
10
10
|
suite "::extender" do
|
11
11
|
assert "Should return an Array" do
|
12
|
-
kind_of(Array,
|
12
|
+
kind_of(Array, ::BareTest.extender)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
suite "::format" do
|
17
17
|
assert "Should return a Hash" do
|
18
|
-
kind_of(Hash,
|
18
|
+
kind_of(Hash, ::BareTest.format)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
suite "::toplevel_suite" do
|
23
|
-
assert "Should return an instance of
|
24
|
-
kind_of(::
|
23
|
+
assert "Should return an instance of BareTest::Suite" do
|
24
|
+
kind_of(::BareTest::Suite, ::BareTest.toplevel_suite)
|
25
25
|
end
|
26
26
|
|
27
|
-
assert "Should be used by
|
28
|
-
test = ::
|
27
|
+
assert "Should be used by BareTest::suite" do
|
28
|
+
test = ::BareTest.clone # avoid interfering with the current run
|
29
29
|
test.init
|
30
30
|
suites_before = test.toplevel_suite.suites.size
|
31
|
-
test.
|
31
|
+
test.suite "A new suite" do end
|
32
32
|
suites_after = test.toplevel_suite.suites.size
|
33
33
|
|
34
34
|
equal(suites_before+1, suites_after)
|
35
35
|
end
|
36
36
|
|
37
|
-
assert "Should be used by
|
38
|
-
test = ::
|
37
|
+
assert "Should be used by BareTest::run_if_mainfile" do
|
38
|
+
test = ::BareTest.clone # avoid interfering with the current run
|
39
39
|
test.init
|
40
40
|
suites_before = test.toplevel_suite.suites.size
|
41
41
|
test.run_if_mainfile "A new suite" do end
|
@@ -44,23 +44,23 @@ Test.define "Test" do
|
|
44
44
|
equal(suites_before+1, suites_after)
|
45
45
|
end
|
46
46
|
|
47
|
-
assert "Should be run by
|
47
|
+
assert "Should be run by BareTest::run" do
|
48
48
|
this = self # needed because touch is called in the block of another assertion, so otherwise it'd be local to that assertion
|
49
|
-
test = ::
|
49
|
+
test = ::BareTest.clone # avoid interfering with the current run
|
50
50
|
test.init
|
51
|
-
test.
|
51
|
+
test.suite "A new suite" do assert do this.touch(:assertion_executed) end end
|
52
52
|
test.run
|
53
53
|
|
54
54
|
touched(:assertion_executed)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
suite "::
|
59
|
-
assert "Should add the contained suites and asserts to
|
60
|
-
test = ::
|
58
|
+
suite "::suite" do
|
59
|
+
assert "Should add the contained suites and asserts to BareTest::toplevel_suite" do
|
60
|
+
test = ::BareTest.clone # avoid interfering with the current run
|
61
61
|
test.init
|
62
62
|
suites_before = test.toplevel_suite.suites.size
|
63
|
-
test.
|
63
|
+
test.suite "A new suite" do end
|
64
64
|
suites_after = test.toplevel_suite.suites.size
|
65
65
|
|
66
66
|
equal(suites_before+1, suites_after)
|
@@ -71,14 +71,14 @@ Test.define "Test" do
|
|
71
71
|
setup do
|
72
72
|
ENV['FORMAT'] = 'minimal'
|
73
73
|
@ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
74
|
-
@test_path = Shellwords.escape(File.expand_path("#{__FILE__}
|
75
|
-
@wrap_path = Shellwords.escape(File.expand_path("#{__FILE__}
|
76
|
-
@inc_path = Shellwords.escape(File.dirname(
|
74
|
+
@test_path = Shellwords.escape(File.expand_path("#{__FILE__}/../../../external/bootstraptest.rb"))
|
75
|
+
@wrap_path = Shellwords.escape(File.expand_path("#{__FILE__}/../../../external/bootstrapwrap.rb"))
|
76
|
+
@inc_path = Shellwords.escape(File.dirname(BareTest.required_file))
|
77
77
|
end
|
78
78
|
|
79
79
|
suite "File is the program" do
|
80
80
|
assert "Should run the suite" do
|
81
|
-
IO.popen("#{@ruby} -I#{@inc_path} -
|
81
|
+
IO.popen("#{@ruby} -I#{@inc_path} -rbaretest #{@test_path}") { |sio|
|
82
82
|
sio.read
|
83
83
|
} =~ /\ATests: 1\nSuccess: 1\nPending: 0\nFailures: 0\nErrors: 0\nTime: [^\n]+\nStatus: success\n\z/
|
84
84
|
end
|
@@ -86,7 +86,7 @@ Test.define "Test" do
|
|
86
86
|
|
87
87
|
suite "File is not the program" do
|
88
88
|
assert "Should not run the suite if the file is not the program" do
|
89
|
-
IO.popen("#{@ruby} -I#{@inc_path} -
|
89
|
+
IO.popen("#{@ruby} -I#{@inc_path} -rbaretest #{@wrap_path}") { |sio|
|
90
90
|
sio.read
|
91
91
|
} =~ /\ADone\n\z/
|
92
92
|
end
|
@@ -94,11 +94,11 @@ Test.define "Test" do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
suite "::run" do
|
97
|
-
assert "Should run
|
97
|
+
assert "Should run BareTest's toplevel suite" do
|
98
98
|
this = self # needed because touch is called in the block of another assertion, so otherwise it'd be local to that assertion
|
99
|
-
test = ::
|
99
|
+
test = ::BareTest.clone # avoid interfering with the current run
|
100
100
|
test.init
|
101
|
-
test.
|
101
|
+
test.suite "A new suite" do assert do this.touch(:assertion_executed) end end
|
102
102
|
test.run
|
103
103
|
|
104
104
|
touched(:assertion_executed)
|
@@ -108,10 +108,10 @@ Test.define "Test" do
|
|
108
108
|
suite "Skipped" do
|
109
109
|
suite "Suite" do
|
110
110
|
setup do
|
111
|
-
parent = ::
|
111
|
+
parent = ::BareTest::Suite.new
|
112
112
|
parent.setup do end
|
113
113
|
parent.teardown do end
|
114
|
-
@suite = ::
|
114
|
+
@suite = ::BareTest::Skipped::Suite.new("None", parent)
|
115
115
|
@suite.setup do end
|
116
116
|
@suite.teardown do end
|
117
117
|
end
|
@@ -144,36 +144,36 @@ Test.define "Test" do
|
|
144
144
|
assert "Should add new skipped assertions to a suite." do
|
145
145
|
equal(
|
146
146
|
:expected => 0,
|
147
|
-
:actual => @suite.
|
147
|
+
:actual => @suite.assertions.size,
|
148
148
|
:message => "number of defined tests before adding any"
|
149
149
|
)
|
150
150
|
|
151
151
|
@suite.assert "a"
|
152
152
|
equal(
|
153
153
|
:expected => 1,
|
154
|
-
:actual => @suite.
|
154
|
+
:actual => @suite.skipped.size,
|
155
155
|
:message => "number of defined tests after adding one"
|
156
156
|
)
|
157
157
|
|
158
158
|
@suite.assert "b"
|
159
159
|
equal(
|
160
160
|
:expected => 2,
|
161
|
-
:actual => @suite.
|
161
|
+
:actual => @suite.skipped.size,
|
162
162
|
:message => "number of defined tests after adding two"
|
163
163
|
)
|
164
164
|
|
165
165
|
equal_unordered(
|
166
166
|
:expected => ['a', 'b'],
|
167
|
-
:actual => @suite.
|
167
|
+
:actual => @suite.skipped.map { |child| child.description },
|
168
168
|
:message => "the descriptions"
|
169
169
|
)
|
170
170
|
|
171
|
-
@suite.
|
171
|
+
@suite.skipped.all? { |test| kind_of(::BareTest::Skipped::Assertion, test) }
|
172
172
|
end
|
173
173
|
|
174
174
|
assert "Added tests should have the receiving suite as suite." do
|
175
175
|
@suite.assert "a"
|
176
|
-
assertion = @suite.
|
176
|
+
assertion = @suite.skipped.first
|
177
177
|
|
178
178
|
same(
|
179
179
|
:expected => @suite,
|
@@ -188,7 +188,7 @@ Test.define "Test" do
|
|
188
188
|
suite "#execute" do
|
189
189
|
suite "Given a test that succeeds" do
|
190
190
|
assert "Should have status :skipped" do
|
191
|
-
assertion = ::
|
191
|
+
assertion = ::BareTest::Skipped::Assertion.new(nil, "") do true end
|
192
192
|
assertion.execute
|
193
193
|
|
194
194
|
equal(:skipped, assertion.status)
|
@@ -197,7 +197,7 @@ Test.define "Test" do
|
|
197
197
|
|
198
198
|
suite "Given a test that is pending" do
|
199
199
|
assert "Should have status :skipped" do
|
200
|
-
assertion = ::
|
200
|
+
assertion = ::BareTest::Skipped::Assertion.new(nil, "")
|
201
201
|
assertion.execute
|
202
202
|
|
203
203
|
equal(:skipped, assertion.status)
|
@@ -206,7 +206,7 @@ Test.define "Test" do
|
|
206
206
|
|
207
207
|
suite "Given a test that fails" do
|
208
208
|
assert "Should have status :skipped" do
|
209
|
-
assertion = ::
|
209
|
+
assertion = ::BareTest::Skipped::Assertion.new(nil, "") do false end
|
210
210
|
assertion.execute
|
211
211
|
|
212
212
|
equal(:skipped, assertion.status)
|
@@ -215,7 +215,7 @@ Test.define "Test" do
|
|
215
215
|
|
216
216
|
suite "Given a test that errors" do
|
217
217
|
assert "Should have status :skipped" do
|
218
|
-
assertion = ::
|
218
|
+
assertion = ::BareTest::Skipped::Assertion.new(nil, "") do raise end
|
219
219
|
assertion.execute
|
220
220
|
|
221
221
|
equal(:skipped, assertion.status)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baretest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rusterholz
|
@@ -9,59 +9,80 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-27 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: |-
|
17
|
+
Baretest is a Testframework that tries to stay out of your way, but support
|
18
|
+
you when you want it. In order to do so it has a load of features:
|
17
19
|
email: stefan.rusterholz@gmail.com
|
18
|
-
executables:
|
19
|
-
|
20
|
+
executables:
|
21
|
+
- baretest
|
20
22
|
extensions: []
|
21
23
|
|
22
24
|
extra_rdoc_files: []
|
23
25
|
|
24
26
|
files:
|
27
|
+
- LICENSE.txt
|
25
28
|
- MANIFEST.txt
|
26
|
-
- README.
|
29
|
+
- README.rdoc
|
27
30
|
- bin/baretest
|
31
|
+
- doc/baretest.rdoc
|
32
|
+
- doc/mocking_stubbing_test_doubles.rdoc
|
33
|
+
- doc/quickref.rdoc
|
34
|
+
- doc/writing_tests.rdoc
|
35
|
+
- examples/tests/irb_mode/failures.rb
|
36
|
+
- examples/tests/mock_developer/test/helper/mocks.rb
|
37
|
+
- examples/tests/mock_developer/test/setup.rb
|
38
|
+
- examples/tests/mock_developer/test/suite/mock_demo.rb
|
39
|
+
- examples/tests/overview/test.rb
|
40
|
+
- examples/tests/variations/variations_01.rb
|
41
|
+
- examples/tests/variations/variations_02.rb
|
42
|
+
- examples/tests/variations/variations_03.rb
|
28
43
|
- examples/test.rake
|
29
|
-
-
|
30
|
-
- lib/
|
31
|
-
- lib/
|
32
|
-
- lib/
|
33
|
-
- lib/
|
34
|
-
- lib/
|
35
|
-
- lib/
|
36
|
-
- lib/
|
37
|
-
- lib/
|
38
|
-
- lib/
|
39
|
-
- lib/
|
40
|
-
- lib/
|
41
|
-
- lib/
|
42
|
-
- lib/
|
43
|
-
- lib/
|
44
|
-
- lib/
|
45
|
-
- lib/
|
44
|
+
- lib/baretest.rb
|
45
|
+
- lib/baretest/assertion.rb
|
46
|
+
- lib/baretest/assertion/context.rb
|
47
|
+
- lib/baretest/assertion/failure.rb
|
48
|
+
- lib/baretest/assertion/skip.rb
|
49
|
+
- lib/baretest/assertion/support.rb
|
50
|
+
- lib/baretest/irb_mode.rb
|
51
|
+
- lib/baretest/layout.rb
|
52
|
+
- lib/baretest/mocha.rb
|
53
|
+
- lib/baretest/run.rb
|
54
|
+
- lib/baretest/run/cli.rb
|
55
|
+
- lib/baretest/run/errors.rb
|
56
|
+
- lib/baretest/run/minimal.rb
|
57
|
+
- lib/baretest/run/profile.rb
|
58
|
+
- lib/baretest/run/spec.rb
|
59
|
+
- lib/baretest/run/tap.rb
|
60
|
+
- lib/baretest/run/xml.rb
|
61
|
+
- lib/baretest/setup.rb
|
62
|
+
- lib/baretest/skipped.rb
|
63
|
+
- lib/baretest/skipped/assertion.rb
|
64
|
+
- lib/baretest/skipped/suite.rb
|
65
|
+
- lib/baretest/suite.rb
|
66
|
+
- lib/baretest/utilities.rb
|
67
|
+
- lib/baretest/version.rb
|
46
68
|
- test/external/bootstraptest.rb
|
47
69
|
- test/external/bootstrapwrap.rb
|
48
70
|
- test/helper/mocks.rb
|
49
|
-
- test/lib/test.rb
|
50
|
-
- test/lib/test/assertion.rb
|
51
|
-
- test/lib/test/assertion/support.rb
|
52
|
-
- test/lib/test/debug.rb
|
53
|
-
- test/lib/test/irb_mode.rb
|
54
|
-
- test/lib/test/run.rb
|
55
|
-
- test/lib/test/run/cli.rb
|
56
|
-
- test/lib/test/run/errors.rb
|
57
|
-
- test/lib/test/run/interactive.rb
|
58
|
-
- test/lib/test/run/spec.rb
|
59
|
-
- test/lib/test/run/tap.rb
|
60
|
-
- test/lib/test/run/xml.rb
|
61
|
-
- test/lib/test/suite.rb
|
62
71
|
- test/setup.rb
|
72
|
+
- test/suite/lib/baretest.rb
|
73
|
+
- test/suite/lib/baretest/assertion.rb
|
74
|
+
- test/suite/lib/baretest/assertion/support.rb
|
75
|
+
- test/suite/lib/baretest/irb_mode.rb
|
76
|
+
- test/suite/lib/baretest/run.rb
|
77
|
+
- test/suite/lib/baretest/run/cli.rb
|
78
|
+
- test/suite/lib/baretest/run/errors.rb
|
79
|
+
- test/suite/lib/baretest/run/interactive.rb
|
80
|
+
- test/suite/lib/baretest/run/spec.rb
|
81
|
+
- test/suite/lib/baretest/run/tap.rb
|
82
|
+
- test/suite/lib/baretest/run/xml.rb
|
83
|
+
- test/suite/lib/baretest/suite.rb
|
63
84
|
has_rdoc: true
|
64
|
-
homepage: http://
|
85
|
+
homepage: http://baretest.rubyforge.org
|
65
86
|
licenses: []
|
66
87
|
|
67
88
|
post_install_message:
|
@@ -73,7 +94,7 @@ rdoc_options:
|
|
73
94
|
- --tab-width
|
74
95
|
- "2"
|
75
96
|
- -t
|
76
|
-
- baretest
|
97
|
+
- baretest-0.2.3 Documentation
|
77
98
|
require_paths:
|
78
99
|
- lib
|
79
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -91,9 +112,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
112
|
requirements: []
|
92
113
|
|
93
114
|
rubyforge_project: baretest
|
94
|
-
rubygems_version: 1.3.
|
115
|
+
rubygems_version: 1.3.5
|
95
116
|
signing_key:
|
96
117
|
specification_version: 3
|
97
|
-
summary: "A
|
118
|
+
summary: "A testframework that doesn\xE2\x80\x99t stand in your way or forces you to learn a new language. Two methods is all that is required to know."
|
98
119
|
test_files: []
|
99
120
|
|
data/README.markdown
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
Bare Test
|
2
|
-
=========
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
Summary
|
7
|
-
-------
|
8
|
-
|
9
|
-
A minimal Testframework.
|
10
|
-
Three methods to use it, Twenty to master it, about hundred lines of code[1].
|
11
|
-
Bare Test, try it and you'll love it.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Description
|
16
|
-
-----------
|
17
|
-
|
18
|
-
Baretest is a Testframework that tries to stay out of your way, but support you when you want it.
|
19
|
-
In order to do so it has a load of features:
|
20
|
-
|
21
|
-
* Strightforward and terse assertions (just a block whose return value defines
|
22
|
-
success/failure)
|
23
|
-
* Easy grouping of assertions into suites
|
24
|
-
* BDD style specifications/test descriptions (NOT code), also extractable
|
25
|
-
* Uncomplicated dependency testing and skipping
|
26
|
-
* Helpers to deal painlessly with raising, throwing, float imprecision,
|
27
|
-
unordered collections etc.
|
28
|
-
* Ships with colored Shell formatter, Diagnostic-, Interactive-, XML- and TAP
|
29
|
-
formatter
|
30
|
-
* Interactive formatter - drops you into an irb session within failed assertion
|
31
|
-
with all setup methods executed, so you can inspect interactively why it
|
32
|
-
failed.
|
33
|
-
* Trivial to add new formatters (the standard formatters are only roughly 20-50
|
34
|
-
lines of code each)
|
35
|
-
* Teardown and Setup for suites
|
36
|
-
* Callbacks to integrate mock libraries
|
37
|
-
* API to use it from code, such as rake tasks (comes with an example rake-task)
|
38
|
-
* baretest executable to run tests on multiple files at once
|
39
|
-
* Diagnostic assertion helpers (e.g. same(:a, :b) will give you 'Expected
|
40
|
-
:a but got :b' as diagnostic)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
Quick Try
|
45
|
-
---------
|
46
|
-
|
47
|
-
1. Download from github and unpack (or clone)
|
48
|
-
2. Change into the baretest directory: `cd the/baretest/directory`
|
49
|
-
3. Run the examples: `./bin/baretest examples/test.rb`
|
50
|
-
|
51
|
-
That's it. Alternatively you can run baretests own tests, and play with formatters:
|
52
|
-
`./bin/baretest -f tap`
|
53
|
-
|
54
|
-
Unfortunately the installer and gem installer aren't ready yet.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
Executable
|
59
|
-
----------
|
60
|
-
|
61
|
-
Usage: baretest [options] [glob, ...]
|
62
|
-
Glob defaults to 'test/**/*.rb'
|
63
|
-
Providing a directory as glob is equivalent to dir/**/*.rb
|
64
|
-
Options:
|
65
|
-
-f, --format FORMAT use FORMAT for output
|
66
|
-
-F, --formats show available formats
|
67
|
-
-d, --debug set debugging flags (set $DEBUG to true)
|
68
|
-
-i, --interactive drop into IRB on error or failure
|
69
|
-
-s, --setup FILE specify setup file
|
70
|
-
-v, --version print the version and exit
|
71
|
-
-w, --warn turn warnings on for your script
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
Planned Features
|
76
|
-
----------------
|
77
|
-
|
78
|
-
* --fail-all flag, to test/review diagnostics of tests
|
79
|
-
* Word-wrapping for CLI runner
|
80
|
-
* Flags for color and verbose (\[no-]color and \[no-]verbose) for the executable
|
81
|
-
* Passing on flags/options for formatters
|
82
|
-
* Alternative CLI runner with status implicit via colored/bg-colored descriptions
|
83
|
-
* Alternative CLI runner which prints the name of the test prior the label and rewrites
|
84
|
-
the line when the test has executed to add status & coloring.
|
85
|
-
* Simple stubbing with automatic cleanup at teardown. Example:
|
86
|
-
|
87
|
-
assert "Should require a single file listed in :requires option." do |a|
|
88
|
-
file = 'foo/bar'
|
89
|
-
stub(Kernel, :require) do |file, *args| a.touch(file) end
|
90
|
-
::Test::Suite.create(nil, nil, :requires => file)
|
91
|
-
|
92
|
-
touched file
|
93
|
-
end
|
94
|
-
|
95
|
-
* Inline tests via Module#describe (basically the same as Test::Suite#suite)
|
96
|
-
* YARD code to extract the specifications without running the code
|
97
|
-
* A redmine plugin
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
Rejected Features
|
102
|
-
-----------------
|
103
|
-
|
104
|
-
* Currently none
|
105
|
-
|
106
|
-
|
107
|
-
A Bit of Background
|
108
|
-
-------------------
|
109
|
-
|
110
|
-
Originally, bare-test started out as a project for shits & giggles on the flight
|
111
|
-
back from vegas (railsconf09), to prove that it is possible to have a fully
|
112
|
-
fledged test-framework in under 100 lines of source-code.
|
113
|
-
Later I realized that this project could become more. For one it was (still is)
|
114
|
-
dead simple to add another formatter, it is just as dead simple to embedd it
|
115
|
-
in code.
|
116
|
-
The principles are trivial to understand, embrace and extend.
|
117
|
-
Upon that it dawned me, that the project was viable and I began adding features
|
118
|
-
not found in other projects.
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
Example Testsuite
|
123
|
-
-----------------
|
124
|
-
|
125
|
-
From examples/test.rb:
|
126
|
-
|
127
|
-
Test.run_if_mainfile do
|
128
|
-
# assertions and refutations can be grouped in suites. They will share
|
129
|
-
# setup and teardown
|
130
|
-
# they don't have to be in suites, though
|
131
|
-
suite "Success" do
|
132
|
-
assert "An assertion returning a trueish value (non nil/false) is a success" do
|
133
|
-
true
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
suite "Failure" do
|
138
|
-
assert "An assertion returning a falsish value (nil/false) is a failure" do
|
139
|
-
false
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
suite "Pending" do
|
144
|
-
assert "An assertion without a block is pending"
|
145
|
-
end
|
146
|
-
|
147
|
-
suite "Error" do
|
148
|
-
assert "Uncaught exceptions in an assertion are an error" do
|
149
|
-
raise "Error!"
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
suite "Special assertions" do
|
154
|
-
assert "Assert a block to raise" do
|
155
|
-
raises do
|
156
|
-
sleep(rand()/3+0.05)
|
157
|
-
raise "If this raises then the assertion is a success"
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
assert "Assert a float to be close to another" do
|
162
|
-
a = 0.18 - 0.01
|
163
|
-
b = 0.17
|
164
|
-
within_delta a, b, 0.001
|
165
|
-
end
|
166
|
-
|
167
|
-
suite "Nested suite" do
|
168
|
-
assert "Assert two randomly ordered arrays to contain the same values" do
|
169
|
-
a = [*"A".."Z"] # an array with values from A to Z
|
170
|
-
b = a.sort_by { rand }
|
171
|
-
a.equal_unordered(b) # can be used with any Enumerable, uses hash-key identity
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
suite "Setup & Teardown" do
|
177
|
-
setup do
|
178
|
-
@foo = "foo"
|
179
|
-
@bar = "bar"
|
180
|
-
end
|
181
|
-
|
182
|
-
assert "@foo should be set" do
|
183
|
-
@foo == "foo"
|
184
|
-
end
|
185
|
-
|
186
|
-
suite "Nested suite" do
|
187
|
-
setup do
|
188
|
-
@bar = "inner bar"
|
189
|
-
@baz = "baz"
|
190
|
-
end
|
191
|
-
|
192
|
-
assert "@foo is inherited" do
|
193
|
-
@foo == "foo"
|
194
|
-
end
|
195
|
-
|
196
|
-
assert "@bar is overridden" do
|
197
|
-
@bar == "inner bar"
|
198
|
-
end
|
199
|
-
|
200
|
-
assert "@baz is defined only for inner" do
|
201
|
-
@baz == "baz"
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
teardown do
|
206
|
-
@foo = nil # not that it'd make much sense, just to demonstrate
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
suite "Dependencies", :requires => ['foo', 'bar'] do
|
211
|
-
assert "Will be skipped, due to unsatisfied dependencies" do
|
212
|
-
raise "This code therefore will never be executed"
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
Known bugs
|
220
|
-
----------
|
221
|
-
|
222
|
-
* touch/touched have to clean up after every Assertion#execute. Should use the mock hooks.
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
Foot Notes
|
227
|
-
----------
|
228
|
-
[1]: "" The abbreviated form without support code and output formatters.
|
229
|
-
The normal code is expanded to more lines for readability.
|
data/examples/test.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'test'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
Test.run_if_mainfile do
|
6
|
-
# assertions and refutations can be grouped in suites. They will share
|
7
|
-
# setup and teardown
|
8
|
-
# they don't have to be in suites, though
|
9
|
-
suite "Success" do
|
10
|
-
assert "An assertion returning a trueish value (non nil/false) is a success" do
|
11
|
-
true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
suite "Failure" do
|
16
|
-
assert "An assertion returning a falsish value (nil/false) is a failure" do
|
17
|
-
false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
suite "Pending" do
|
22
|
-
assert "An assertion without a block is pending"
|
23
|
-
end
|
24
|
-
|
25
|
-
suite "Error" do
|
26
|
-
assert "Uncaught exceptions in an assertion are an error" do
|
27
|
-
raise "Error!"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
suite "Special assertions" do
|
32
|
-
assert "Assert a block to raise" do
|
33
|
-
raises do
|
34
|
-
sleep(rand()/3+0.05)
|
35
|
-
raise "If this raises then the assertion is a success"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
assert "Assert a float to be close to another" do
|
40
|
-
a = 0.18 - 0.01
|
41
|
-
b = 0.17
|
42
|
-
within_delta a, b, 0.001
|
43
|
-
end
|
44
|
-
|
45
|
-
suite "Nested suite" do
|
46
|
-
assert "Assert two randomly ordered arrays to contain the same values" do
|
47
|
-
a = [*"A".."Z"] # an array with values from A to Z
|
48
|
-
b = a.sort_by { rand }
|
49
|
-
equal_unordered(a, b) # can be used with any Enumerable, uses hash-key identity
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
suite "Setup & Teardown" do
|
55
|
-
setup do
|
56
|
-
@foo = "foo"
|
57
|
-
@bar = "bar"
|
58
|
-
end
|
59
|
-
|
60
|
-
assert "@foo should be set" do
|
61
|
-
@foo == "foo"
|
62
|
-
end
|
63
|
-
|
64
|
-
suite "Nested suite" do
|
65
|
-
setup do
|
66
|
-
@bar = "inner bar"
|
67
|
-
@baz = "baz"
|
68
|
-
end
|
69
|
-
|
70
|
-
assert "@foo is inherited" do
|
71
|
-
@foo == "foo"
|
72
|
-
end
|
73
|
-
|
74
|
-
assert "@bar is overridden" do
|
75
|
-
@bar == "inner bar"
|
76
|
-
end
|
77
|
-
|
78
|
-
assert "@baz is defined only for inner" do
|
79
|
-
@baz == "baz"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
teardown do
|
84
|
-
@foo = nil # not that it'd make much sense, just to demonstrate
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
suite "Dependencies", :requires => ['foo', 'bar'] do
|
89
|
-
assert "Will be skipped, due to unsatisfied dependencies" do
|
90
|
-
failure "Why the heck do you have a 'foo/bar' file?"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|