Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29359

"unit test" code on the Wiki page fails with Exception when "./target" folder does not exist.

XMLWordPrintable

      I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

      {{

      @Rule public JenkinsRule j = new JenkinsRule();
      @Test public void first() throws Exception

      { FreeStyleProject project = j.createFreeStyleProject(); project.getBuildersList().add(new Shell("echo hello")); FreeStyleBuild build = project.scheduleBuild2(0).get(); System.out.println(build.getDisplayName() + " completed"); // TODO: change this to use HtmlUnit String s = FileUtils.readFileToString(build.getLogFile()); assertThat(s, contains("+ echo hello")); }}

      it failed with exception when it could not create a folder inside "./target" because "./target" does not exist in my project folder.

      java.lang.Exception: Failed to initialize exploded war
      at org.jvnet.hudson.test.WarExploder.getExplodedDir(WarExploder.java:49) at org.jvnet.hudson.test.JenkinsRule.createWebServer(JenkinsRule.java:578) at
      Caused by: java.io.FileNotFoundException: C:\projects\jenkins-publisher-plugin\.\target\jenkins-for-test.exploding (The system cannot find the path specified)
      at java.io.FileOutputStream.open(Native Method)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
      at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
      at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)

            daspilker Daniel Spilker
            alskor Alex Java
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: