在Grails 3中运行Grails功能测试

问题描述 投票:1回答:1

这似乎是Grails提供的一个非常基本的功能,但我无法开始工作。我正在尝试使用here提供的文档为我的应用程序添加一些API测试。

添加测试并运行grails test-app -integration后,我没有看到测试被执行。以下是该命令的输出。

➜  myProj git:(func-test) ✗ grails test-app -integration

> Configure project :
BUILD SUCCESSFUL in 0s
6 actionable tasks: 6 up-to-date
| Tests PASSED

我没有看到任何测试被执行。

以下是我期待失败的测试。

package myApp

import grails.test.mixin.integration.Integration
import grails.transaction.*

import spock.lang.*
import geb.spock.*

/**
 * See http://www.gebish.org/manual/current/ for more instructions
 */
@Integration
@Rollback
class UsersSpec extends GebSpec {

    def setup() {
    }

    def cleanup() {
    }

    void "visit homepage"() {
        when:"The home page is visited"
            go '/'

        then:"The title is correct"
            title == "Welcome to My Application"
    }
}

我还尝试使用以下命令直接运行测试类:

grails test-app myApp.UsersSpec
grails test-app -integration myApp.UsersSpec
grails test-app -functional
grails test-app -functional myApp.UsersSpec

但他们似乎都没有执行所需的测试。

grails functional-testing grails3 web-api-testing
1个回答
0
投票

假设您的测试是在src/integration-test/groovy/下定义的,并且您在重新配置测试源文件夹方面没有做任何异常,那么您可以通过多种方式运行它们。我建议使用Gradle:

./gradlew integrationTest

(如果你在Windows上,请关闭./

© www.soinside.com 2019 - 2024. All rights reserved.