using junit 4 in grails

前端 未结 4 1023
醉话见心
醉话见心 2021-01-06 16:32

I\'d like to use some JUnit 4 functionality in my grails testing, but currently grails tests run under JUnit 3. JUnit 4 can be used from groovy but replacing the JUnit jar w

4条回答
  •  执笔经年
    2021-01-06 17:11

    As of Grails 1.3.6, it looks like Junit 4 is supported incompletely. Integration tests are fine in Junit 4, but unit tests that extend GrailsUnitTestCase are limited to Junit 3. GrailsUnitTestCase extends GroovyTestCase which is still tied to Junit 3.

    In the Groovy doc (http://groovy.codehaus.org/Using+JUnit+4+with+Groovy) it says that Junit 4 is supported, but notice the statement "Currently, there are no special Groovy extensions for JUnit 4". So you can use it, but none of the Groovy test extensions take advantage of it.

    This is a killer for unit tests that need to use any of the Grails test extensions like mockDomain. I'm proceeding on the assumption that I'm effectively stuck with Junit 3.

提交回复
热议问题