tunit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +113 -0
- data/Rakefile +9 -0
- data/example_spec.rb +35 -0
- data/example_test.rb +23 -0
- data/lib/tunit.rb +83 -0
- data/lib/tunit/assertion_errors.rb +43 -0
- data/lib/tunit/assertions.rb +68 -0
- data/lib/tunit/autorun.rb +8 -0
- data/lib/tunit/compound_reporter.rb +33 -0
- data/lib/tunit/hooks.rb +11 -0
- data/lib/tunit/progress_reporter.rb +11 -0
- data/lib/tunit/reporter.rb +39 -0
- data/lib/tunit/runnable.rb +51 -0
- data/lib/tunit/spec.rb +77 -0
- data/lib/tunit/summary_reporter.rb +50 -0
- data/lib/tunit/test.rb +104 -0
- data/lib/tunit/version.rb +3 -0
- data/test/rtest_test.rb +19 -0
- data/test/tunit/assertion_errors_test.rb +95 -0
- data/test/tunit/assertions_test.rb +68 -0
- data/test/tunit/progress_reporter_test.rb +45 -0
- data/test/tunit/reporter_test.rb +66 -0
- data/test/tunit/runnable_test.rb +69 -0
- data/test/tunit/spec_test.rb +57 -0
- data/test/tunit/summary_reporter_test.rb +116 -0
- data/test/tunit/test_case.rb +72 -0
- data/test/tunit/test_test.rb +181 -0
- data/tunit.gemspec +24 -0
- metadata +127 -0
@@ -0,0 +1,181 @@
|
|
1
|
+
require_relative './test_case'
|
2
|
+
|
3
|
+
module Tunit
|
4
|
+
class TestTest < TestCase
|
5
|
+
def test_runnable_methods
|
6
|
+
assert_equal Test::PREFIX, /^test_/
|
7
|
+
assert_includes PassingTest.runnable_methods, "test_pass"
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_runnable_methods_shuffles_the_tests
|
11
|
+
assert_equal :random, PassingTest.test_order
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_order_bang_orders_your_tests
|
15
|
+
sucky_test = Class.new(PassingTest) {
|
16
|
+
order!
|
17
|
+
}
|
18
|
+
assert_equal :alpha, sucky_test.test_order
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_run_handles_assertions
|
22
|
+
result = PassingTest.new.run
|
23
|
+
|
24
|
+
assert result.passed?
|
25
|
+
assert_equal 1, result.assertions
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_run_handles_failures
|
29
|
+
result = FailingTest.new.run
|
30
|
+
|
31
|
+
exp_msg = "Failed assertion, no message given."
|
32
|
+
failure = result.failure
|
33
|
+
|
34
|
+
assert_instance_of Tunit::Assertion, failure
|
35
|
+
assert_equal exp_msg, failure.message
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_run_handles_empty_tests
|
39
|
+
result = FailingTest.new(:test_empty).run
|
40
|
+
|
41
|
+
exp_msg = "Empty test, 'Tunit::TestCase::FailingTest#test_empty'"
|
42
|
+
failure = result.failure
|
43
|
+
|
44
|
+
assert_instance_of Tunit::Empty, failure
|
45
|
+
assert_equal exp_msg, failure.message
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_run_handles_skipped_tests
|
49
|
+
result = SkippedTest.new.run
|
50
|
+
|
51
|
+
exp_msg = "Skipped 'test_skip'"
|
52
|
+
failure = result.failure
|
53
|
+
|
54
|
+
assert result.skipped?
|
55
|
+
assert_instance_of Tunit::Skip, failure
|
56
|
+
assert_equal exp_msg, failure.message
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_run_skipped_tests_can_have_customized_messages
|
60
|
+
result = SkippedTest.new(:test_skip_with_msg).run
|
61
|
+
|
62
|
+
exp_msg = "implement me when IQ > 80"
|
63
|
+
failure = result.failure
|
64
|
+
|
65
|
+
assert_equal exp_msg, failure.message
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_run_passes_through_errors
|
69
|
+
assert_raises NoMethodError do
|
70
|
+
PassingTest.new(:non_existing_method).run
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_run_times_each_run
|
75
|
+
result = PassingTest.new.run
|
76
|
+
|
77
|
+
assert_instance_of Float, result.time
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_run_execs_setup_before_each_run
|
81
|
+
PassingTest.send(:define_method, :setup) {
|
82
|
+
fail NotImplementedError, "setup dispatch"
|
83
|
+
}
|
84
|
+
|
85
|
+
e = assert_raises NotImplementedError do
|
86
|
+
PassingTest.new.run
|
87
|
+
end
|
88
|
+
|
89
|
+
assert_equal "setup dispatch", e.message
|
90
|
+
|
91
|
+
ensure
|
92
|
+
PassingTest.send :undef_method, :setup
|
93
|
+
PassingTest.send(:define_method, :setup) { }
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_run_execs_teardown_after_each_run
|
97
|
+
PassingTest.send(:define_method, :teardown) {
|
98
|
+
fail NotImplementedError, "teardown dispatch"
|
99
|
+
}
|
100
|
+
|
101
|
+
e = assert_raises NotImplementedError do
|
102
|
+
PassingTest.new.run
|
103
|
+
end
|
104
|
+
|
105
|
+
assert_equal "teardown dispatch", e.message
|
106
|
+
|
107
|
+
ensure
|
108
|
+
PassingTest.send :undef_method, :teardown
|
109
|
+
PassingTest.send(:define_method, :teardown) { }
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_passed_eh
|
113
|
+
result = PassingTest.new.run
|
114
|
+
assert result.passed?
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_passed_eh_is_only_true_if_not_a_failure
|
118
|
+
result = FailingTest.new.run
|
119
|
+
refute result.passed?
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_failure
|
123
|
+
result = FailingTest.new.run
|
124
|
+
|
125
|
+
assert_instance_of ::Tunit::Assertion, result.failure
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_skipped_eh
|
129
|
+
result = SkippedTest.new.run
|
130
|
+
|
131
|
+
assert_instance_of ::Tunit::Skip, result.failure
|
132
|
+
assert result.skipped?
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_code_for_success
|
136
|
+
result = PassingTest.new.run
|
137
|
+
|
138
|
+
assert_equal ".", result.code
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_code_for_failure
|
142
|
+
result = FailingTest.new.run
|
143
|
+
|
144
|
+
assert_equal "F", result.code
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_code_for_skipped
|
148
|
+
result = SkippedTest.new.run
|
149
|
+
|
150
|
+
assert_equal "S", result.code
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_code_for_empty_test
|
154
|
+
result = FailingTest.new(:test_empty).run
|
155
|
+
|
156
|
+
assert_equal "_", result.code
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_location_of_a_failing_test
|
160
|
+
result = FailingTest.new(:test_fail).run
|
161
|
+
exp_location = %r(Tunit::TestCase::FailingTest#test_fail \[test/tunit/test_case.rb:\d{1,}\])
|
162
|
+
|
163
|
+
assert_match exp_location, truncate_absolut_path(result.location)
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_to_s_returns_the_klass_and_test
|
167
|
+
result = PassingTest.new(:test_pass).run
|
168
|
+
exp_klass_and_test = "Tunit::TestCase::PassingTest#test_pass"
|
169
|
+
|
170
|
+
assert_equal exp_klass_and_test, result.to_s
|
171
|
+
assert_equal result.to_s, result.location
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_to_s_returns_the_failing_test
|
175
|
+
result = FailingTest.new(:test_fail).run
|
176
|
+
exp_match = %r(Tunit::TestCase::FailingTest#test_fail \[test/tunit/test_case.rb:\d{1,}\])
|
177
|
+
|
178
|
+
assert_match exp_match, truncate_absolut_path(result.to_s)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
data/tunit.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tunit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tunit"
|
8
|
+
spec.version = Tunit::VERSION
|
9
|
+
spec.authors = ["Teo Ljungberg"]
|
10
|
+
spec.email = ["teo.ljungberg@gmail.com"]
|
11
|
+
spec.summary = %q{My take on a TDD testing framework}
|
12
|
+
spec.description = %q{It's basicly minitest}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tunit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Teo Ljungberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: It's basicly minitest
|
56
|
+
email:
|
57
|
+
- teo.ljungberg@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- example_spec.rb
|
68
|
+
- example_test.rb
|
69
|
+
- lib/tunit.rb
|
70
|
+
- lib/tunit/assertion_errors.rb
|
71
|
+
- lib/tunit/assertions.rb
|
72
|
+
- lib/tunit/autorun.rb
|
73
|
+
- lib/tunit/compound_reporter.rb
|
74
|
+
- lib/tunit/hooks.rb
|
75
|
+
- lib/tunit/progress_reporter.rb
|
76
|
+
- lib/tunit/reporter.rb
|
77
|
+
- lib/tunit/runnable.rb
|
78
|
+
- lib/tunit/spec.rb
|
79
|
+
- lib/tunit/summary_reporter.rb
|
80
|
+
- lib/tunit/test.rb
|
81
|
+
- lib/tunit/version.rb
|
82
|
+
- test/rtest_test.rb
|
83
|
+
- test/tunit/assertion_errors_test.rb
|
84
|
+
- test/tunit/assertions_test.rb
|
85
|
+
- test/tunit/progress_reporter_test.rb
|
86
|
+
- test/tunit/reporter_test.rb
|
87
|
+
- test/tunit/runnable_test.rb
|
88
|
+
- test/tunit/spec_test.rb
|
89
|
+
- test/tunit/summary_reporter_test.rb
|
90
|
+
- test/tunit/test_case.rb
|
91
|
+
- test/tunit/test_test.rb
|
92
|
+
- tunit.gemspec
|
93
|
+
homepage: ''
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.2.2
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: My take on a TDD testing framework
|
117
|
+
test_files:
|
118
|
+
- test/rtest_test.rb
|
119
|
+
- test/tunit/assertion_errors_test.rb
|
120
|
+
- test/tunit/assertions_test.rb
|
121
|
+
- test/tunit/progress_reporter_test.rb
|
122
|
+
- test/tunit/reporter_test.rb
|
123
|
+
- test/tunit/runnable_test.rb
|
124
|
+
- test/tunit/spec_test.rb
|
125
|
+
- test/tunit/summary_reporter_test.rb
|
126
|
+
- test/tunit/test_case.rb
|
127
|
+
- test/tunit/test_test.rb
|