gpt4 book ai didi

grails - 了解Grails中的单元测试

转载 作者:行者123 更新时间:2023-12-02 14:03:28 24 4
gpt4 key购买 nike

我是一个初学者。并试图了解单元测试..
当我创建域类Author grails时,会自动为该域创建测试 Controller AuthorControllerTests

这样。在测试 Controller 中,第二行是@Mock(Author)

这是什么意思..当我模拟域类时,我有什么优势?

最佳答案

extensive documentation on testing中所说:

The Mock annotation creates mock version of any collaborators. There is an in-memory implementation of GORM that will simulate most interactions with the GORM API. For those interactions that are not automatically mocked you can use the built in support for defining mocks and stubs programmatically.



AuthorControllerTests也是AuthorController的测试,而不是Author域类的测试。

关于grails - 了解Grails中的单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11272159/

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