|
2 | 2 |
|
3 | 3 | [Homepage](http://rubyworks.github.com/rubytest) / |
4 | 4 | [User Guide](http://wiki.github.com/rubyworks/rubytest) / |
5 | | -[Development](http://github.com/rubyworks/rubytest) / |
6 | | -[Issues](http://github.com/rubyworks/rubytest/issues) |
| 5 | +[Support](http://github.com/rubyworks/rubytest/issues) / |
| 6 | +[Development](http://github.com/rubyworks/rubytest) |
7 | 7 |
|
8 | 8 | [](http://travis-ci.org/rubyworks/rubytest) |
9 | 9 | [](http://badge.fury.io/rb/rubytest) |
@@ -57,50 +57,64 @@ also be installed in an FHS compliant fashion if necessary. |
57 | 57 |
|
58 | 58 | ## Running Tests |
59 | 59 |
|
60 | | -There are a few ways to run tests. First, there is the command line tool |
61 | | -e.g. |
| 60 | +There are a few ways to run tests. |
62 | 61 |
|
63 | | - $ rubytest test/test_*.rb |
| 62 | +### Via Runner Scripts |
64 | 63 |
|
65 | | -The command line tool takes various options, use `-h/--help` to see them. |
| 64 | +Out of the box Ruby Test doesn't provide any special means for doing so, |
| 65 | +you simply write you own runner script using the Ruby Test API. |
| 66 | +Here is the basic example: |
66 | 67 |
|
67 | | -When running tests, you need to be sure to load in your test framework |
68 | | -or your framework's Ruby Test adapter. This is usually done via a helper |
69 | | -script in the test files, but might also be done via command line options, |
70 | | -e.g. |
| 68 | + require 'rubytest' |
71 | 69 |
|
72 | | - $ rubytest -r lemon -r ae test/test_*.rb |
| 70 | + Test.run! do |r| |
| 71 | + r.loadpath 'lib' |
| 72 | + r.test_files 'test/test_*.rb' |
| 73 | + end |
| 74 | + |
| 75 | +Put that in a `test/runner.rb` script and run it with `ruby` or |
| 76 | +add `#!/usr/bin/env ruby` at the top and put it in `bin/test` |
| 77 | +setting `chmod u+x bin/test`. Either way, you now have your test |
| 78 | +runner. |
| 79 | + |
| 80 | +### Via Command-line Tool |
73 | 81 |
|
74 | | -Ruby Test supports [dotopts](http://rubyworks.github.com/dotopts) out of the |
75 | | -box, so it easy to setup reusable options. For example, a `.option` file |
76 | | -entry might be: |
| 82 | +Probably the easiest way to run tests is via the command line tool available |
| 83 | +via the `rubytest-cli` plug-in. You can read more about it on its |
| 84 | +[webpage](http://rubyworks.github.com/rubytest-cli), but we will quickly go |
| 85 | +over it here. |
77 | 86 |
|
78 | | - rubytest |
79 | | - -f progress |
80 | | - -r spectroscope |
81 | | - -r rspecial |
82 | | - spec/spec_*.rb |
| 87 | +The basic usage example is: |
83 | 88 |
|
84 | | -If you are using a build tool to run your tests, such as Rake or Fire, it is |
85 | | -best to shell out to `rubytest`. This keeps your test environent as prestine |
86 | | -as possible. |
| 89 | + $ rubytest -Ilib test/test_*.rb |
| 90 | + |
| 91 | +The command line tool takes various options, most of which correspond directly |
| 92 | +to the configuration options of the `Test.run/Test.configure` API. Use |
| 93 | +`-h/--help` to see them all. |
| 94 | + |
| 95 | +If you are using a build tool to run your tests, such as Rake or Ergo, shelling |
| 96 | +out to `rubytest` is a good way to go as it keeps your test environment as |
| 97 | +prestine as possible, e.g. |
87 | 98 |
|
88 | 99 | desc "run tests" |
89 | 100 | task :test |
90 | 101 | sh "rubytest" |
91 | 102 | end |
92 | 103 |
|
93 | | -RubyTest comes with a Rake task plugin, but its use is all but deprecated |
94 | | -because it's basically just a glorified rendition of the above. |
| 104 | +### Via Rake Task |
| 105 | + |
| 106 | +There is also a Rake plug-in that can be installed called `rubytest-rake`. |
| 107 | +Surf over to its [webpage](http://rubyworks.github.com/rubytest-rake) for details. |
| 108 | +A basic example in its case, add to one's Rakefile: |
95 | 109 |
|
96 | 110 | require 'rubytest/rake' |
97 | 111 |
|
98 | 112 | Test::Rake::TestTask.new :test do |run| |
99 | 113 | run.requires << 'lemon' |
100 | | - run.files = 'test/test_*.rb' |
| 114 | + run.test_files = 'test/test_*.rb' |
101 | 115 | end |
102 | 116 |
|
103 | | -See the Wiki for more information on the different ways to run tests. |
| 117 | +See the Wiki for more detailed information on the different ways to run tests. |
104 | 118 |
|
105 | 119 |
|
106 | 120 | ## Requirements |
|
0 commit comments