Zastanawia mnie w w jaki sposób powiniem rozwiązać sytuację bo dostaję takiego errora :
org.spockframework.runtime.InvalidSpecException: Stub 'fileLinkRepository' matches the following required interaction:
12 * fileLinkRepository.findAll() (0 invocations)
Remove the cardinality (e.g. '1 *'), or turn the stub into a mock.
W jaki sposób zamienić Stab na Mock w tym teście:
class FileExistTest extends Specification {
FileLinkRepository fileLinkRepository = Stub()
FileExist fileExist = new FileExist(fileLinkRepository)
def "should return given file name if file name is empty"() {
given:
String fileName = ""
when:
String actualName = fileExist.renameFileIfTheSameNameExists(fileName)
then:
actualName == fileName
}
def "should invoke findAll from repository only once"() {
given:
fileLinkRepository = Mock();
when:
fileExist.renameFileIfTheSameNameExists(_ as String)
then:
12 * fileLinkRepository.findAll()
}
to rozwiazanie nie działa wyświetla:
Too few invocations for:
12 * fileLinkRepository.findAll() (0 invocations)
Unmatched invocations (ordered by similarity):
None