gpt4 book ai didi

grails - Grails 3.0生成的ControllerSpec

转载 作者:行者123 更新时间:2023-12-02 15:56:33 25 4
gpt4 key购买 nike

仍然是Grails的新手,非常喜欢学习和解决问题,但有时候看起来很简单的事情只会让我感到困惑。

Grails生成的ControllerSpec类包括一些明智的测试,其中大多数都很简单明了,但是有人可以在此测试中向我解释一些语法/逻辑:

    void "Test the index action returns the correct model"() {

when:"The index action is executed"
controller.index()

then:"The model is correct"
!model.fooBarList
model.fooBarCount == 0
}

特别是以下几行:
!model.fooBarList

逻辑似乎对我来说是错误的,调用 controller.index()将填充 model.fooBarList,那么为什么断言它不存在?

我完全希望在这里能过一会儿,但我需要到达那里的帮助!

最佳答案

The logic seems wrong to me, calling controller.index() will populate model.fooBarList so why assert that it doesn't exist?



并不是说 fooBarList不存在。 model.fooBarList应该是一个空列表,也将通过该测试。

关于grails - Grails 3.0生成的ControllerSpec,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33520977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com