首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >grails cobertura findAllBy

grails cobertura findAllBy
EN

Stack Overflow用户
提问于 2018-10-09 16:04:31
回答 1查看 56关注 0票数 0

我有grails 2.4.4和Cobertura作为隐蔽测试。我的代码如下:

代码语言:javascript
复制
lstPerspectives = Perspectives.findAllByDbAndSysDelete(dbInstance, new Long(0)) 

但是Cobertura没有通过测试,因为没有在我的数据库中搜索,我如何通过此行?如何覆盖此值?我发送了这个lstPerspectives,但它不接受它。

谢谢

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-10-10 18:24:04

尝试如下所示:

代码语言:javascript
复制
import grails.test.mixin.Mock
import grails.test.mixin.TestFor

@TestFor(Perspectives)
@Mock([Perspectives])
class PerspectivesSpec 
{
    void "test Perspectives"(){
        given:
            def dbInstance = 'aDbInstance' // don't know what this is
            def sysDelete = false // is this a boolean?
            new Perspectives( dbInstance: dbInstance, sysDelete: sysDelete ).save( failOnError: true )
        when:
            // run you bit of code that executes the snippet in your question
        then:
             // check your desired outcome
    }
}

我不知道你是直接在这里测试你的透视类,还是别的什么,控制器,服务?所以我不得不做一些假设。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52716125

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档