My first  approach was to simply:

public class JenkinsApiTest {
  public void test()  {
    ItemGroup<Item> itemGroup = new MyItemGroup();
    FreeStyleProject p = new FreeStyleProject(itemGroup, "n0");
    p.getConfigFile().asString();
  }

this results in the AbstractProject constructor being called:

    protected AbstractProject(ItemGroup parent, String name) {
        super(parent,name);

        if(!Jenkins.getInstance().getNodes().isEmpty()) {
            // if a new job is configured with Hudson that already has slave
nodes
            // make it roamable by default
            canRoam = true;
        }
    }

which throws a NullPointerException most likely because a Jenkins instance
has not been created. I seems that creating types from hudson.model.*
package requires a running Jenkins instance and hence the whole
HudsonTestCase setup is necessary



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Creating-a-FreeStyleProject-outside-JUnit-tp4651594p4651931.html
Sent from the Jenkins users mailing list archive at Nabble.com.

Reply via email to