glv / micronaut-unit
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
.document | ||
| |
.gitignore | ||
| |
LICENSE | ||
| |
README.md | ||
| |
Rakefile | ||
| |
VERSION.yml | ||
| |
examples/ | ||
| |
lib/ | ||
| |
micronaut-unit.gemspec |
micronaut-unit
Test::Unit compatibility for micronaut.
Just add this to your code:
require 'micronaut/unit'
and then you can write test classes like this:
class FooTest < Micronaut::Unit::TestCase
def test_foo
assert_equal 3, Foo::major_version
end
end
Using the testinfo method, you can attach metadata to the next
defined test (this works much the same way Rake's desc method
attaches a description string to the next defined task):
testinfo :speed => 'slow', :run => 'nightly' def
test_tarantula_multipass
# ...
end
Each instance of Micronaut::Unit::TestCase is equivalent to a
micronaut describe block, so it can also include it blocks,
before and after blocks, and nested describe blocks. Test
methods and it blocks can contain either assertions or should
expressions. test blocks (as found in Rails 2.x) also work.
Additionally, assertions can be used inside ordinary micronaut examples.
Rationale
The point of this gem is not that I think test/unit is a better way to write tests than the RSpec style. I admit that I'm a TDD oldtimer who sees RSpec as mostly a cosmetic (rather than fundamental) change, but that doesn't mean it's not an important change. My curmudgeonly nature has its limits, and I do find specs a big improvement.
So why micronaut-unit? Three reasons:
- I wanted to show off the generality of Micronaut's architecture. On the surface, Micronaut might not seem all that compelling (since it's basically an RSpec work-alike). But it's really a fantastic tool; it's just that the innovation is all under the hood, in a way that makes it easy to change the surface aspects. I hope micronaut-unit can serve as an example for anyone who wants to experiment with new ways of expressing tests and specs on top of Micronaut.
- Many projects with existing test/unit test suites might want to benefit from Micronaut's metadata goodness, or begin a gradual, piecemeal change to an RSpec style. That's pretty easy to do with micronaut-unit.
- Even when writing specs and examples, I frequently encounter
cases where an assertion is more expressive than a
shouldexpression. It's nice just to have assertions supported within Micronaut examples.
To Do
It would be nice to try using the assertion code from minitest, which is much more compact and seems less coupled than that from test/unit.
Copyright
Copyright (c) 2009 Glenn Vanderburg. See LICENSE for details.

