3

在 groovy.util.GroovyTestCase ( http://groovy.codehaus.org/api/groovy/util/GroovyTestCase.html ) 的文档中,描述说“Groovy 中的默认 JUnit TestCase。这提供了许多帮助方法以及避免要求所有 test* 方法为 void return type 的 JUnit 限制

但是,当我使用如下 groovy JUnit3 代码时,JUnit 找不到任何测试:

class MyTest extends GroovyTestCase {
    def testSomething() {
        assert 1 + 1 == 2
    }
}

如果我将 testSomething() 的返回类型更改为 void(在 JUnit 中是正常的),则发现测试很好。

我需要以不同的方式编写测试还是文档错误?

4

1 回答 1

0

Here is the source for v 2.2.1 of GroovyTestCase. I believe that your assertion is correct: the doc is wrong.

I don't see any code that supports the claim, and even in the case for the notYetImplemented feature, the method isPublicTestMethod clearly looks for void (and implies the code is from JUnit itself). This last point isn't related to your code, per se, but further suggests the comment is off base.

于 2014-03-12T01:22:51.653 回答