Yeah, I think you are making a lot of sense here.
For example, I haven't been able to get into RSpec. I know a lot of people
really like it and it's gained a lot of popularity recently, but it's not
for me.
The interface just "feels" wrong to me. To give a random example, I can't
imagine how I would explain to a programming student something like, "Now we
can check that valid?() method you just wrote using be_valid()." I would
much rather be saying, "OK, let's call valid?() a few times and see if we
get the results we expect."
I like RSpec in a lot of ways, but this stuff annoys me too. The
trouble is the lack of bare assertions and the dogmatic assumption
that introducing them could be evil. But I don't know, my inner
Rubyist and non-conformist asks me, why shouldn't I just be able to do
this?
class Thing
def valid?
false
end
end
def assert(thing)
(!!thing).should be_true
end
describe "A thing" do
it "should be valid" do
@thing = Thing.new
assert @thing.valid?
end
end
It's not like this code is hard to follow, but it's annoying that I
need to create a custom hack to support the most basic thing (a simple
assert).
But hacking in some less magic alternatives to RSpec isn't exactly
appealing. Things like Shoulda and test/spec and friends already do
that. What I'd really want in Test::Unit to make it feel like a good
solution 'out of the box' is:
* Some standard mocking library - Mocha is very pretty IMO, but any would do
* Full Test::Unit compatibility to play nice with the massive amount
of pre-existing tests out there
* Flexibility to extend the framework to go in the direction *I* want
it to. I'm personally quite sick of people telling me that I'm doing
something wrong because it doesn't read like English, or because I use
a setup method that creates a 'dependency' between the tests. Though
these are valid conversations to have, people need to stop acting like
there are established laws, and should give us the freedom to bend our
tools to our work flow, not the other way around.
* The ability to specify my test cases as strings rather than methods
like test_something_should_do_something
* The ability to have contexts and nested contexts.
* Nice built in extras to do pretty HTML reports, coverage reports, etc.
I know there are some efforts heading in this direction, but I feel
like standard Ruby should really ship with something that accomplishes
all of the above. I don't hate BDD style syntax, but it's the last
reason why I use RSpec. The lack of compatibility with other testing
tools creates a divide that I don't like, too.
It mostly seems that people who are accustomed to Test::Unit are more
tolerant and willing to write specs if necessary, but that BDD
advocates who are convinced they've learned "The One True Way" of
doing things really have a strong aversion to going back to xunit
style syntax. Seems like a mental hangup to me.
Anyway, what I've said applies only to a small percentage of people
I've encountered in the community, but they have seemed to be quite
vocal.
I am mostly thinking that RSpec owes a huge chunk of its success to
its glittering side-features, and not the BDD syntax magic. I wonder
if others feel the same way.
-greg