Module: Cybertrain::Test
- Defined in:
- cybertrain/test.rb,
cybertrain/test/client.rb
Overview
The test harness for applications (and the frameworkâs own tests).
minitest and RSpec cannot run under Spinel, so a test file is a plain
program: it registers cases with the top-level test "name" do ... end,
asserts with the top-level assert* methods (see the
overview), and ends with
Cybertrain::Test.run!. For requests, see Client.
cybertrain spin test compiles each test/*.rb (not test/support/)
into its own program and compares its output with test/<name>.rb.expected.
There is no setup/teardown and no isolation between cases: reset what
you need at the top of a case (e.g. Article.all.delete_all).
Defined Under Namespace
Classes: AssertionFailed, Client
Class Method Summary collapse
-
.run!
Runs every registered case in registration order, prints one line per case plus a summary, and exits non-zero when anything failed.
Class Method Details
.run!
This method returns an undefined value.
Runs every registered case in registration order, prints one line per case plus a summary, and exits non-zero when anything failed.
The lines are ok <name>, FAIL <name>: <message> for a failed
assertion, ERR <name>: <Class>: <message> for another exception,
then <n> tests, <n> assertions, <n> failures. Call it at the end of
every test file.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'cybertrain/test.rb', line 67 def self.run! @@cases.each do |c| begin c.block.call puts "ok #{c.name}" rescue AssertionFailed => e @@failures += 1 puts "FAIL #{c.name}: #{e.}" rescue StandardError => e @@failures += 1 puts "ERR #{c.name}: #{e.class.name}: #{e.}" end end puts "#{@@cases.size} tests, #{@@assertions} assertions, #{@@failures} failures" exit(1) if @@failures > 0 end |