Building Jenkins plugin tests with JenkinsRule class
I am trying to unit test Jenkins Plugins using JenkinsRule
All the tests suggest this kind of approach
package hudson.plugins.xxxx;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.tasks.Shell;
import org.junit.*;
import org.jvnet.hudson.test.JenkinsRule;
public class Apptest{
@Rule public JenkinsRule jenkinsRule = new JenkinsRule();
@Test public void first() throws Exception {
FreeStyleProject project = jenkinsRule.createFreeStyleProject();
project.getBuildersList().add(new Shell("echo hello"));
FreeStyleBuild build = project.scheduleBuild2(0).get();
}
}
as per the example https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test
But jenkinsRule.createFreeStyleProject() is a protected method and wont
let me call it. How Should I test the builder
No comments:
Post a Comment