简体   繁体   中英

How to Grails 3 integration test in IntelliJ IDEA

I'm not able to run an integration test in IntelliJ IDEA. Here is a test template generated by grails create-integration-test

@Integration
@Rollback
class TestServiceIntSpec extends Specification{
 void "test something"() {
   //some code here
 }
}

Here is the output when I'm trying to run it from junit configuration :

Process finished with exit code 0
Empty test suite.

Also seems like grails using development env if I'm running this test from IDE, I have to specify env explicitly via -Dgrails.env=test

Spock测试('规范')通过以下时间确定哪些方法是测试when:then:或者expect:等等。

HypeMK's answer is correct. To elaborate, the following test may not run because it does not have the presence of the spock keywords that outline the specification nature of the test (expect, when, then, etc):

@TestFor(BeanFormTagLib)
class BeanFormTagLibSpec extends Specification {
    def setup() {}

    void "address setup"() {
        assertOutputEquals ('Hello World', '<g:beanFormTagLib domainName="com.myapp.Address" />');
    }
}

Here we correct the issue by adding the "expect" keyword:

@TestFor(BeanFormTagLib)
class BeanFormTagLibSpec extends Specification {
    def setup() {}
    void "address setup"() {
        expect:
        assertOutputEquals ('Hello World', '<g:beanFormTagLib domainName="com.myapp.Address" />');
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM