Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
测试Jenkins使用的groovy类_Jenkins_Gradle_Groovy - Fatal编程技术网

测试Jenkins使用的groovy类

测试Jenkins使用的groovy类,jenkins,gradle,groovy,Jenkins,Gradle,Groovy,我在Jenkins构建使用的groovy文件中有一个函数: def hasFlag(name, required_count = 1) { 20 if (!fileExists(successFile()) && canSaveFlag()) { 19 copyArtifacts( 18 filter: '_buildmeta/*', 17 optional: true, 16 projectName: configura

我在Jenkins构建使用的groovy文件中有一个函数:

def hasFlag(name, required_count = 1) {
 20   if (!fileExists(successFile()) && canSaveFlag()) {
 19     copyArtifacts(
 18       filter: '_buildmeta/*',
 17       optional: true,
 16       projectName: configuration.gitJobName(),
 14       selector: lastCompleted()
 13     )
 12     archiveArtifacts(artifacts: '_buildmeta/*', allowEmptyArchive: true)
 11   }
 10   def result = false
  9   if (fileExists(successFile())) {
  7     def lines = readFile(successFile()).split('\n')
  5     def count = lines.count { it == "|$name|" }
  3     result = required_count <= count
  2   }
  1   return result
59  }

有什么东西可以用来测试这个函数吗?

你可以模拟缺少的函数。还有一个专门针对Jenkins管道的测试框架
java.lang.NoSuchMethodError: No such DSL method 'lastCompleted' found among steps