1

我尝试使用 JenkinsPipelineUnit 执行的管道有一些导入和完整路径类。

import org.jenkins.plugins.lockableresources.LockableResourcesManager

(...)

} catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {

(...)

在我声明测试(使用 Java/Junit5)后:

@BeforeEach
void setup() throws Exception {
    setUp();
    
    Binding binding = getBinding();
    binding.setVariable("MY_VARIABLE", "MY_VALUE");
    (...)

    PipelineTestHelper helper = getHelper();
    helper.registerAllowedMethod("getFreeResourceAmount", List.of(String.class), null);
    (...)

}

@Test
void test1() {
    Script script = loadScript("/path/to/jenkinsfile");
    script.run();
    assertJobStatusSuccess();
}

如何使用帮助程序或其他组件来允许测试解析类?

org.jenkins.plugins.lockableresources.LockableResourcesManager
hudson.tasks.test.AbstractTestResultAction

4

0 回答 0