test-unit 3.1.5 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/BSDL +24 -0
  3. data/COPYING +41 -41
  4. data/README.md +24 -17
  5. data/Rakefile +21 -24
  6. data/doc/text/getting-started.md +246 -0
  7. data/doc/text/news.md +797 -56
  8. data/lib/test/unit/assertion-failed-error.rb +35 -0
  9. data/lib/test/unit/assertions.rb +542 -220
  10. data/lib/test/unit/attribute.rb +78 -4
  11. data/lib/test/unit/auto-runner-loader.rb +17 -0
  12. data/lib/test/unit/autorunner.rb +175 -78
  13. data/lib/test/unit/code-snippet-fetcher.rb +7 -7
  14. data/lib/test/unit/collector/descendant.rb +1 -0
  15. data/lib/test/unit/collector/dir.rb +4 -2
  16. data/lib/test/unit/collector/load.rb +25 -15
  17. data/lib/test/unit/collector/objectspace.rb +1 -0
  18. data/lib/test/unit/collector.rb +31 -0
  19. data/lib/test/unit/color-scheme.rb +29 -2
  20. data/lib/test/unit/data-sets.rb +127 -0
  21. data/lib/test/unit/data.rb +121 -12
  22. data/lib/test/unit/diff.rb +10 -11
  23. data/lib/test/unit/fixture.rb +77 -27
  24. data/lib/test/unit/notification.rb +9 -7
  25. data/lib/test/unit/omission.rb +34 -31
  26. data/lib/test/unit/pending.rb +12 -11
  27. data/lib/test/unit/priority.rb +7 -5
  28. data/lib/test/unit/runner/console.rb +20 -1
  29. data/lib/test/unit/test-suite-creator.rb +30 -9
  30. data/lib/test/unit/testcase.rb +349 -196
  31. data/lib/test/unit/testresult.rb +7 -0
  32. data/lib/test/unit/testsuite.rb +1 -1
  33. data/lib/test/unit/ui/console/testrunner.rb +171 -60
  34. data/lib/test/unit/ui/emacs/testrunner.rb +5 -5
  35. data/lib/test/unit/ui/testrunnermediator.rb +9 -7
  36. data/lib/test/unit/util/backtracefilter.rb +17 -5
  37. data/lib/test/unit/util/memory-usage.rb +47 -0
  38. data/lib/test/unit/util/observable.rb +2 -2
  39. data/lib/test/unit/util/output.rb +5 -4
  40. data/lib/test/unit/util/procwrapper.rb +4 -4
  41. data/lib/test/unit/version.rb +1 -1
  42. data/lib/test/unit/warning.rb +3 -0
  43. data/lib/test/unit.rb +177 -161
  44. data/lib/test-unit.rb +2 -17
  45. metadata +20 -94
  46. data/GPL +0 -339
  47. data/LGPL +0 -502
  48. data/test/collector/test-descendant.rb +0 -178
  49. data/test/collector/test-load.rb +0 -442
  50. data/test/collector/test_dir.rb +0 -406
  51. data/test/collector/test_objectspace.rb +0 -100
  52. data/test/fixtures/header-label.csv +0 -3
  53. data/test/fixtures/header-label.tsv +0 -3
  54. data/test/fixtures/header.csv +0 -3
  55. data/test/fixtures/header.tsv +0 -3
  56. data/test/fixtures/no-header.csv +0 -2
  57. data/test/fixtures/no-header.tsv +0 -2
  58. data/test/fixtures/plus.csv +0 -3
  59. data/test/run-test.rb +0 -22
  60. data/test/test-assertions.rb +0 -2157
  61. data/test/test-attribute-matcher.rb +0 -38
  62. data/test/test-attribute.rb +0 -123
  63. data/test/test-code-snippet.rb +0 -37
  64. data/test/test-color-scheme.rb +0 -82
  65. data/test/test-color.rb +0 -47
  66. data/test/test-data.rb +0 -281
  67. data/test/test-diff.rb +0 -518
  68. data/test/test-emacs-runner.rb +0 -60
  69. data/test/test-error.rb +0 -26
  70. data/test/test-failure.rb +0 -33
  71. data/test/test-fault-location-detector.rb +0 -163
  72. data/test/test-fixture.rb +0 -659
  73. data/test/test-notification.rb +0 -33
  74. data/test/test-omission.rb +0 -81
  75. data/test/test-pending.rb +0 -70
  76. data/test/test-priority.rb +0 -173
  77. data/test/test-test-case.rb +0 -1171
  78. data/test/test-test-result.rb +0 -113
  79. data/test/test-test-suite-creator.rb +0 -97
  80. data/test/test-test-suite.rb +0 -150
  81. data/test/testunit-test-util.rb +0 -31
  82. data/test/ui/test_testrunmediator.rb +0 -20
  83. data/test/util/test-method-owner-finder.rb +0 -38
  84. data/test/util/test-output.rb +0 -11
  85. data/test/util/test_backtracefilter.rb +0 -41
  86. data/test/util/test_observable.rb +0 -102
  87. data/test/util/test_procwrapper.rb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 86673156c68b86e03890136de7cac26b04ebf6ba
4
- data.tar.gz: e2e15e416b83d09eee253273f981ef4a9c2566f5
2
+ SHA256:
3
+ metadata.gz: 229f08041ec90505679800d12fdf5fca1f70623f5d4b91b54ee5e75bb171efe5
4
+ data.tar.gz: 5d51111b001089cf72b69c4df3e11a8d590e8be03497ffa22b9f5bc48219296a
5
5
  SHA512:
6
- metadata.gz: e6d3ea4e758eb002dad57e91d1db3a7f71ff12e1a6428c115db9c619cbd9b054606f74a8b9aeed216c6ab9d9a37d257d6f4521d9dcfbfa60966073c41b0b67fc
7
- data.tar.gz: 09d14bdfc97c567d50c1b2feaac261cad406256c86bbe9be809c48f012dd845a76be20bd94e29190ce77580bfee96ddbc94f0f309b990eb97521cd22d72b9b59
6
+ metadata.gz: 2b655e8a13f61513ef4b4574766fb94003416890d3b30f1bed2831c2a48d6606705752bb100dd15bbdcfcdc76f2c87bd8c086b8b7b6c6223982e81b93e9d91c4
7
+ data.tar.gz: 16293a67ec4a26eb23c7f57784dba2ef5c76f5fb952645a7a1654db217f4e12791424ca6264395ae7c2669560af3ecbc560f23ae27c7cdbaa7268474911d519d
data/BSDL ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (C) 2003-2007 Nathaniel Talbott. All rights reserved.
2
+ Copyright (C) 2008 Ryan Davis. All rights reserved.
3
+ Copyright (C) 2008-2020 Sutou Kouhei. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions
7
+ are met:
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
+ SUCH DAMAGE.
data/COPYING CHANGED
@@ -2,63 +2,63 @@ test-unit is copyrighted free software by Kouhei Sutou
2
2
  <kou@cozmixng.org>, Ryan Davis <ryand-ruby@zenspider.com>
3
3
  and Nathaniel Talbott <nathaniel@talbott.ws>.
4
4
 
5
- You can redistribute it and/or modify it under either the terms of the GPL
6
- version 2 (see the file GPL), or the conditions below:
5
+ You can redistribute it and/or modify it under either the terms of the
6
+ 2-clause BSDL (see the file BSDL), or the conditions below:
7
7
 
8
- 1. You may make and give away verbatim copies of the source form of the
9
- software without restriction, provided that you duplicate all of the
10
- original copyright notices and associated disclaimers.
8
+ 1. You may make and give away verbatim copies of the source form of the
9
+ software without restriction, provided that you duplicate all of the
10
+ original copyright notices and associated disclaimers.
11
11
 
12
- 2. You may modify your copy of the software in any way, provided that
13
- you do at least ONE of the following:
12
+ 2. You may modify your copy of the software in any way, provided that
13
+ you do at least ONE of the following:
14
14
 
15
- a) place your modifications in the Public Domain or otherwise
16
- make them Freely Available, such as by posting said
17
- modifications to Usenet or an equivalent medium, or by allowing
18
- the author to include your modifications in the software.
15
+ a. place your modifications in the Public Domain or otherwise
16
+ make them Freely Available, such as by posting said
17
+ modifications to Usenet or an equivalent medium, or by allowing
18
+ the author to include your modifications in the software.
19
19
 
20
- b) use the modified software only within your corporation or
21
- organization.
20
+ b. use the modified software only within your corporation or
21
+ organization.
22
22
 
23
- c) give non-standard binaries non-standard names, with
24
- instructions on where to get the original software distribution.
23
+ c. give non-standard binaries non-standard names, with
24
+ instructions on where to get the original software distribution.
25
25
 
26
- d) make other distribution arrangements with the author.
26
+ d. make other distribution arrangements with the author.
27
27
 
28
- 3. You may distribute the software in object code or binary form,
29
- provided that you do at least ONE of the following:
28
+ 3. You may distribute the software in object code or binary form,
29
+ provided that you do at least ONE of the following:
30
30
 
31
- a) distribute the binaries and library files of the software,
32
- together with instructions (in the manual page or equivalent)
33
- on where to get the original distribution.
31
+ a. distribute the binaries and library files of the software,
32
+ together with instructions (in the manual page or equivalent)
33
+ on where to get the original distribution.
34
34
 
35
- b) accompany the distribution with the machine-readable source of
36
- the software.
35
+ b. accompany the distribution with the machine-readable source of
36
+ the software.
37
37
 
38
- c) give non-standard binaries non-standard names, with
39
- instructions on where to get the original software distribution.
38
+ c. give non-standard binaries non-standard names, with
39
+ instructions on where to get the original software distribution.
40
40
 
41
- d) make other distribution arrangements with the author.
41
+ d. make other distribution arrangements with the author.
42
42
 
43
- 4. You may modify and include the part of the software into any other
44
- software (possibly commercial). But some files in the distribution
45
- are not written by the author, so that they are not under these terms.
43
+ 4. You may modify and include the part of the software into any other
44
+ software (possibly commercial). But some files in the distribution
45
+ are not written by the author, so that they are not under these terms.
46
46
 
47
- For the list of those files and their copying conditions, see the
48
- file LEGAL.
47
+ For the list of those files and their copying conditions, see the
48
+ file LEGAL.
49
49
 
50
- 5. The scripts and library files supplied as input to or produced as
51
- output from the software do not automatically fall under the
52
- copyright of the software, but belong to whomever generated them,
53
- and may be sold commercially, and may be aggregated with this
54
- software.
50
+ 5. The scripts and library files supplied as input to or produced as
51
+ output from the software do not automatically fall under the
52
+ copyright of the software, but belong to whomever generated them,
53
+ and may be sold commercially, and may be aggregated with this
54
+ software.
55
55
 
56
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
57
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
58
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59
- PURPOSE.
56
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
57
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
58
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59
+ PURPOSE.
60
60
 
61
61
  Exceptions
62
62
  ----------
63
63
 
64
- * lib/test/unit/diff.rb: PSFL
64
+ * lib/test/unit/diff.rb: This license and PSF license
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # test-unit
2
2
 
3
- [![](https://badge.fury.io/rb/test-unit.png)](http://badge.fury.io/rb/test-unit)
4
- [![](https://travis-ci.org/test-unit/test-unit.png?branch=master)](https://travis-ci.org/test-unit/test-unit)
3
+ [![Gem Version](https://badge.fury.io/rb/test-unit.png)](http://badge.fury.io/rb/test-unit)
4
+ [![Build Status for Ruby 2.1+](https://github.com/test-unit/test-unit/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/test-unit/test-unit/actions/workflows/test.yml?query=branch%3Amaster+)
5
5
 
6
6
  * http://test-unit.github.io/
7
7
  * https://github.com/test-unit/test-unit
@@ -10,31 +10,42 @@
10
10
 
11
11
  An xUnit family unit testing framework for Ruby.
12
12
 
13
- Test::Unit (test-unit) is unit testing framework for Ruby, based on xUnit
13
+ test-unit (Test::Unit) is unit testing framework for Ruby, based on xUnit
14
14
  principles. These were originally designed by Kent Beck, creator of extreme
15
15
  programming software development methodology, for Smalltalk's SUnit. It allows
16
16
  writing tests, checking results and automated testing in Ruby.
17
17
 
18
+ test-unit ships as part of Ruby as a bundled gem. To check which version is included, see https://stdgems.org/test-unit/.
19
+ It's only necessary to install the gem if you need a newer version.
20
+
21
+ test-unit is the original Ruby unit testing library, and is still active.
22
+ It is one of two unit testing libraries bundled with Ruby, the other being [minitest](https://github.com/minitest/minitest).
23
+
24
+ When deciding which to use, consider:
25
+
26
+ * test-unit is strict about backwards compatibility. A backwards-incompatible change would be considered a bug.
27
+ * test-unit aims to support old Ruby versions, even if EOL.
28
+
18
29
  ## Features
19
30
 
20
- * Test::Unit 1.2.3 is the original Test::Unit, taken
31
+ * test-unit 1.2.3 is the original test-unit, taken
21
32
  straight from the ruby distribution. It is being
22
33
  distributed as a gem to allow tool builders to use it as a
23
34
  stand-alone package. (The test framework in ruby is going
24
35
  to radically change very soon).
25
36
 
26
37
  * test-unit will be improved actively and may break
27
- compatiblity with Test::Unit 1.2.3. (We will not hope it
38
+ compatibility with test-unit 1.2.3. (We will not hope it
28
39
  if it isn't needed.)
29
40
 
30
41
  * Some features exist as separated gems like GUI test
31
42
  runner. (Tk, GTK+ and Fox) test-unit-full gem package
32
- provides for installing all Test::Unit related gems
43
+ provides for installing all test-unit related gems
33
44
  easily.
34
45
 
35
46
  ## How To
36
47
 
37
- * [How To](doc/text/how-to.md) (link for GitHub)
48
+ * [How To](https://github.com/test-unit/test-unit/blob/master/doc/text/how-to.md) (link for GitHub)
38
49
  * {file:doc/text/how-to.md How To} (link for YARD)
39
50
 
40
51
  ## Install
@@ -43,7 +54,7 @@ writing tests, checking results and automated testing in Ruby.
43
54
  % sudo gem install test-unit
44
55
  </pre>
45
56
 
46
- If you want to use full Test::Unit features:
57
+ If you want to use full test-unit features:
47
58
 
48
59
  <pre>
49
60
  % sudo gem install test-unit-full
@@ -51,17 +62,13 @@ If you want to use full Test::Unit features:
51
62
 
52
63
  ## License
53
64
 
54
- (The Ruby License)
55
-
56
- This software is distributed under the same terms as ruby.
65
+ This software is distributed under either the terms of new Ruby
66
+ License or BSDL. See the file [COPYING](COPYING).
57
67
 
58
68
  Exception:
59
69
 
60
- * lib/test/unit/diff.rb is a double license of the Ruby license and
61
- PSF license.
62
-
63
- * lib/test-unit.rb is a dual license of the Ruby license and LGPLv2.1
64
- or later.
70
+ * lib/test/unit/diff.rb is a triple license of (the new Ruby license
71
+ or BSDL) and PSF license.
65
72
 
66
73
  ## Authors
67
74
 
@@ -77,7 +84,7 @@ Exception:
77
84
 
78
85
  ### Images
79
86
 
80
- * Mayu & Co.: kinotan icons: http://cocooooooon.com/kinotan/
87
+ * Mayu & Co.: kinotan icons
81
88
 
82
89
  ## Thanks
83
90
 
data/Rakefile CHANGED
@@ -1,23 +1,18 @@
1
1
  # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2008-2013 Kouhei Sutou <kou@clear-code.com>
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3
+ # Copyright (C) 2008-2017 Kouhei Sutou <kou@clear-code.com>
18
4
 
19
5
  Encoding.default_internal = "UTF-8" if defined?(Encoding.default_internal)
20
6
 
7
+ # TODO: Remove me when we drop Ruby 1.9 support.
8
+ unless "".respond_to?(:b)
9
+ class String
10
+ def b
11
+ dup.force_encoding("ASCII-8BIT")
12
+ end
13
+ end
14
+ end
15
+
21
16
  require "erb"
22
17
  require "yaml"
23
18
  require "rubygems"
@@ -29,7 +24,6 @@ require "packnga"
29
24
  task :default => :test
30
25
 
31
26
  base_dir = File.dirname(__FILE__)
32
- html_base_dir = File.join(base_dir, "doc", "html")
33
27
 
34
28
  helper = Bundler::GemHelper.new(base_dir)
35
29
  def helper.version_tag
@@ -58,14 +52,17 @@ def rake(*arguments)
58
52
  ruby($0, *arguments)
59
53
  end
60
54
 
61
- namespace :html do
62
- desc "Publish HTML to Web site."
63
- task :publish do
64
- # FIXME Do nothing for now
65
- #rsync_to_rubyforge(spec, "#{html_base_dir}/", "")
66
- end
67
- end
68
-
69
55
  task :test do
70
56
  ruby("test/run-test.rb")
71
57
  end
58
+
59
+ namespace :doc do
60
+ task :add_permalink do
61
+ news_md = File.read("doc/text/news.md")
62
+ applied_permalink = news_md.gsub(/(?<pre>\[GitHub#(?<ref>\d+)\])(?!\()/) do
63
+ "#{Regexp.last_match[:pre]}(https://github.com/test-unit/test-unit/issues/#{Regexp.last_match[:ref]})"
64
+ end
65
+
66
+ File.write("doc/text/news.md", applied_permalink)
67
+ end
68
+ end
@@ -0,0 +1,246 @@
1
+ ## 1. First step of the `test-unit`
2
+
3
+ Let's getting start `test-unit`.
4
+
5
+ This document creates an example gem package called `sample` with the `test-unit` testing framework.
6
+
7
+ ## 2. Install bundler and test-unit.
8
+
9
+ * First, install the `bundler` gem for generating gem template.
10
+ * Second, install the `test-unit` itself.
11
+
12
+ ~~~
13
+ !!!plain
14
+ gem install bundler
15
+ gem install test-unit
16
+ ~~~
17
+
18
+ The `gem list` command output installed packages.
19
+ You will find the following lines.
20
+
21
+ ~~~
22
+ !!!plain
23
+ gem list
24
+ ...
25
+ bundler (1.14.6)
26
+ ...
27
+ test-unit (3.2.3)
28
+ ~~~
29
+
30
+ ## 3. Create gem template.
31
+
32
+ Next, create a gem template using `bundler` command.
33
+ This command generates package skeleton with a testing framework.
34
+ However, this command can't generate test templates for `test-unit`.
35
+
36
+ So, First create gem template with the `minitest` testing framework.
37
+ (It's similar to `unit-test`).
38
+ After that, replace some files for `test-unit`.
39
+
40
+ The `bundle gem -t minitest sample` command will generate the following files.
41
+
42
+ ~~~
43
+ !!!plain
44
+ .
45
+ |-- Gemfile
46
+ |-- README.md
47
+ |-- Rakefile
48
+ |-- bin
49
+ | |-- console
50
+ | `-- setup
51
+ |-- lib
52
+ | |-- sample
53
+ | | `-- version.rb
54
+ | `-- sample.rb
55
+ |-- sample.gemspec # <- Modify
56
+ `-- test
57
+ |-- sample_test.rb # <- Modify
58
+ `-- test_helper.rb # <- Modify
59
+ ~~~
60
+
61
+ ## 4. Edit files for `test-unit`
62
+
63
+ ### 4.1. Edit gemspec
64
+
65
+ Edit `sample.gemspec` like the below.
66
+ Replace `minitest` line to `test-unit`.
67
+
68
+ Before
69
+
70
+ ~~~
71
+ !!!ruby
72
+ spec.add_development_dependency "minitest", "~> 5.0"
73
+ ~~~
74
+
75
+ After
76
+
77
+ ~~~
78
+ !!!ruby
79
+ spec.add_development_dependency "test-unit", "~> 3.2.3"
80
+ ~~~
81
+
82
+ ### 4.2. Edit `test/test_helper.rb`
83
+
84
+ Next, edit the `test/test_helper.rb` file.
85
+
86
+ Before
87
+
88
+ ~~~
89
+ !!!ruby
90
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
91
+ require 'sample'
92
+
93
+ require 'minitest/autorun' # <-- Modify this line.
94
+ ~~~
95
+
96
+ After
97
+
98
+ ~~~
99
+ !!!ruby
100
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
101
+ require 'sample'
102
+
103
+ require 'test/unit' # <-- After modification.
104
+ ~~~
105
+
106
+ ### 4.3 Rakefile (No edit)
107
+
108
+ This file doesn't need to modify.
109
+ The output is the below.
110
+
111
+ ~~~
112
+ !!!ruby
113
+ require "bundler/gem_tasks"
114
+ require "rake/testtask"
115
+
116
+ Rake::TestTask.new(:test) do |t|
117
+ t.libs << "test"
118
+ t.libs << "lib"
119
+ t.test_files = FileList['test/**/*_test.rb']
120
+ end
121
+
122
+ task :default => :test
123
+ ~~~
124
+
125
+ ### 4.4 Edit `test/sample_test.rb`
126
+
127
+ The bundler generate the file `test/sample_test.rb`.
128
+ This file originally templates for `minitest`.
129
+
130
+ Let's modify this file for `test-unit`
131
+
132
+ before
133
+
134
+ ~~~
135
+ !!!ruby
136
+ require 'test_helper'
137
+
138
+ class SampleTest < Minitest::Test # <- Modify here
139
+ def test_that_it_has_a_version_number
140
+ refute_nil ::Sample::VERSION
141
+ end
142
+
143
+ def test_it_does_something_useful
144
+ assert false
145
+ end
146
+ end
147
+ ~~~
148
+
149
+ After
150
+
151
+ ~~~
152
+ !!!ruby
153
+ require 'test_helper'
154
+
155
+ class SampleTest < Test::Unit::TestCase # <- After modification
156
+ def test_that_it_has_a_version_number
157
+ refute_nil ::Sample::VERSION
158
+ end
159
+
160
+ def test_it_does_something_useful
161
+ assert false
162
+ end
163
+ end
164
+ ~~~
165
+
166
+ ## 5. Execute test.
167
+
168
+ The `rake test` command execute test scenarios in the `test` directory.
169
+ Now it tries to two tests. One will success the other one fails.
170
+
171
+ ~~~
172
+ !!!plain
173
+ rake test
174
+ Loaded suite
175
+ /path/to/ruby/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/rake_test_loader
176
+ Started
177
+ F
178
+ ================================================================================
179
+ Failure: <false> is not true.
180
+ test_it_does_something_useful(SampleTest)
181
+ /path/to/sample/test/sample_test.rb:9:in `test_it_does_something_useful'
182
+ 6: end
183
+ 7:
184
+ 8: def test_it_does_something_useful
185
+ => 9: assert false
186
+ 10: end
187
+ 11: end
188
+ ================================================================================
189
+ .
190
+
191
+ Finished in 0.011521 seconds.
192
+ --------------------------------------------------------------------------------
193
+ 2 tests, 2 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
194
+ 50% passed
195
+ --------------------------------------------------------------------------------
196
+ 173.60 tests/s, 173.60 assertions/s
197
+ rake aborted!
198
+ Command failed with status (1)
199
+
200
+ Tasks: TOP => test
201
+ (See full trace by running task with --trace)
202
+ ~~~
203
+
204
+ ## 6. Create original tests.
205
+
206
+ Let's create your original tests with the following rules.
207
+
208
+ * Create a test file in the `test` directory.
209
+ * The file needs suffix `xxx_test.rb`.
210
+ * You can put test file into the subdirectory like `test/sub`.
211
+
212
+ Example directory layout.
213
+
214
+ ~~~
215
+ !!!plain
216
+ test
217
+ |-- sample_test.rb
218
+ |-- sub
219
+ | `-- sample2_test.rb
220
+ `-- test_helper.rb
221
+ ~~~
222
+
223
+ Example test file in the sub directory.
224
+
225
+ ~~~
226
+ !!!ruby
227
+ require 'test_helper'
228
+
229
+ module Sub
230
+ class Sample2Test < Test::Unit::TestCase
231
+ def test_that_it_has_a_version_number
232
+ refute_nil ::Sample::VERSION
233
+ end
234
+
235
+ def test_it_does_something_useful
236
+ assert false
237
+ end
238
+ end
239
+ end
240
+ ~~~
241
+
242
+ ## 7. For more information
243
+
244
+ Let's read the official document.
245
+
246
+ * [test-unit](https://test-unit.github.io/index.html)