简体   繁体   English

如何在IntelliJ IDEA中进行Grails 3集成测试

[英]How to Grails 3 integration test in IntelliJ IDEA

I'm not able to run an integration test in IntelliJ IDEA. 我无法在IntelliJ IDEA中运行集成测试。 Here is a test template generated by grails create-integration-test 这是由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 : 这是我尝试从junit配置运行它时的输出:

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 如果我从IDE运行此测试,看起来像grails使用开发环境,我必须通过-Dgrails.env = test明确指定env

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

HypeMK's answer is correct. HypeMK的答案是正确的。 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): 详细说明,以下测试可能无法运行,因为它没有spock关键字的存在,这些关键字概述了测试的规范性质(期望,何时,等等):

@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: 在这里,我们通过添加“expect”关键字来解决问题:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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