【问题标题】:Running Grails functional tests in Grails 3在 Grails 3 中运行 Grails 功能测试
【发布时间】:2017-12-19 08:10:25
【问题描述】:

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

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

➜ myProj git:(func-test) ✗ grails test-app -integration > 配置项目: 在 0 秒内构建成功 6 个可操作的任务:6 个最新的 |测试通过

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

以下是我预计会失败的测试。

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】:

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

    ./gradlew integrationTest
    

    (如果您使用的是 Windows,请关闭 ./

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-14
      • 1970-01-01
      • 2017-02-07
      • 2016-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多