我有grails 2.4.4和Cobertura作为隐蔽测试。我的代码如下:
lstPerspectives = Perspectives.findAllByDbAndSysDelete(dbInstance, new Long(0)) 但是Cobertura没有通过测试,因为没有在我的数据库中搜索,我如何通过此行?如何覆盖此值?我发送了这个lstPerspectives,但它不接受它。
谢谢
谢谢
发布于 2018-10-10 18:24:04
尝试如下所示:
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
}
}我不知道你是直接在这里测试你的透视类,还是别的什么,控制器,服务?所以我不得不做一些假设。
https://stackoverflow.com/questions/52716125
复制相似问题