--
You received this message because you are subscribed to the Google Groups "gosu-lang" group.
To post to this group, send email to gosu...@googlegroups.com.
To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.
--
Hi Carson,1. "method/test names" can be ordinary strings. e.g. for stack the method shouldPopItemOnTop could be "should pop item on top".2. one could nest test methods in multiple contexts. e.g. stack could have a "stack with one item" context and in it an "method" called "should pop item on top".This way writing tests feels more as writing a testable specification.Here are some examples in other languages. Please note that RSpec-style test are not organized in classes. I've also added an example for Spock which actually is a class and runs in JUnit.=== RSpec/Ruby ===# bowling_spec.rbrequire 'bowling'describe Bowling, "#score" doit "returns 0 for all gutter game" dobowling = Bowling.new20.times { bowling.hit(0) }bowling.score.should == 0endend=== SpecIt/QUnit/Javascript ===describe("SpecIt", function() {var john, cachedItems = [];before(function() {john = {name: "John Doe", age: 26};});it("should use before blocks", function() {assert(john.name).should(eql, "John Doe");assert(john.age).should(beLessThan, 30);});});=== Spock/Groovy ===import spock.lang.Specificationclass EmptyStack extends Specification {def stack = new Stack()def "size"() {expect: stack.size() == 0}def "push"() {when:stack.push("elem")then:stack.size() == old(stack.size()) + 1stack.peek() == "elem"}}--Benjamin2011/3/1 Carson Gross <carso...@gmail.com>
But then again, I've never found the RSpec-style that compelling
anyway, so perhaps I'm not the right person to comment in this regard.
I don't see the example Gosu code there as much of an improvement in
terms of either readability or explicitness on:
function testScoreIsZeroForAllGutterGames() {
var bowling = new Bowling()
for(i in 0..20) {
bowling.hit(0)
}
assertThat(bowling.Score).equals(0)
}
In fact, I think the using statement part of it actually makes it
harder to read. If an explicit tie to the method is necessary for the
sake of tools or something, I'd just do it in Javadoc or annotations.
But perhaps there are some other benefits to the RSpec approach that
I'm ignoring?
-Alan
> ...
>
> read more »
https://github.com/akeefer/Tosa/tree/master/tosa-test/test-src/test
and then a usage at:
If you run DBTypeInfoTestWrapper in IntelliJ (I haven't tried Eclipse,
but presumably it's the same), it'll run the underlying wrapped Gosu
test. You can't run individual methods, but you can at least run the
whole test class, and if you use the Gosu plugin for IntelliJ you can
debug the Gosu code as well.
You can also run a suite of tests using something like what Carson
hacked up for the Tosa suite:
https://github.com/akeefer/Tosa/blob/master/tosa-test/test-src/test/TosaSuite.java
It's not ideal, but it's been good enough for me to at least run/debug
my tests in IntelliJ as I work on Tosa.
-Alan