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.

      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)

          [JENKINS-29359] "unit test" code on the Wiki page fails with Exception when "./target" folder does not exist.

          Alex Java created issue -
          Alex Java made changes -
          Description Original: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}public class AppTest {
            @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"));
            }
          }
          {quote}

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

          bq. 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 org.jvnet.hudson.test.JenkinsRule.newHudson(JenkinsRule.java:530) at org.jvnet.hudson.test.JenkinsRule.before(JenkinsRule.java:331) at org.jvnet.hudson.test.JenkinsRule$2.evaluate(JenkinsRule.java:480) at org.junit.rules.RunRules.evaluate(RunRules.java:18) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)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)
          bq.
          bq. java.lang.Exception: Failed to initialize exploded war
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.getExplodedDir(WarExploder.java:49)
          bq.
          bq. at org.jvnet.hudson.test.JenkinsRule.createWebServer(JenkinsRule.java:578)
          bq.
          bq. at org.jvnet.hudson.test.JenkinsRule.newHudson(JenkinsRule.java:530)
          bq.
          bq. at org.jvnet.hudson.test.JenkinsRule.before(JenkinsRule.java:331)
          bq.
          bq. at org.jvnet.hudson.test.JenkinsRule$2.evaluate(JenkinsRule.java:480)
          bq.
          bq. at org.junit.rules.RunRules.evaluate(RunRules.java:18)
          bq.
          bq. at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
          bq.
          bq. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
          bq.
          bq. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
          bq.
          bq. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
          bq.
          bq. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
          bq.
          bq. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
          bq.
          bq. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
          bq.
          bq. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
          bq.
          bq. at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
          bq.
          bq. at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
          bq.
          bq. at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
          bq.
          bq. at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
          bq.
          bq. at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
          bq.
          bq. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          bq.
          bq. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          bq.
          bq. at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)
          bq.
          bq. Caused by: java.io.FileNotFoundException: C:\projects\jenkins-publisher-plugin\.\target\jenkins-for-test.exploding (The system cannot find the path specified)
          bq.
          bq. at java.io.FileOutputStream.open(Native Method)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)
          bq.
          New: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}public class AppTest {
            @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"));
            }
          }
          {quote}

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

          bq. java.lang.Exception: Failed to initialize exploded war
          bq. at org.jvnet.hudson.test.WarExploder.getExplodedDir(WarExploder.java:49) at org.jvnet.hudson.test.JenkinsRule.createWebServer(JenkinsRule.java:578) at
          bq. Caused by: java.io.FileNotFoundException: C:\projects\jenkins-publisher-plugin\.\target\jenkins-for-test.exploding (The system cannot find the path specified)
          bq.
          bq. at java.io.FileOutputStream.open(Native Method)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)
          bq.
          Alex Java made changes -
          Description Original: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}public class AppTest {
            @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"));
            }
          }
          {quote}

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

          bq. java.lang.Exception: Failed to initialize exploded war
          bq. at org.jvnet.hudson.test.WarExploder.getExplodedDir(WarExploder.java:49) at org.jvnet.hudson.test.JenkinsRule.createWebServer(JenkinsRule.java:578) at
          bq. Caused by: java.io.FileNotFoundException: C:\projects\jenkins-publisher-plugin\.\target\jenkins-for-test.exploding (The system cannot find the path specified)
          bq.
          bq. at java.io.FileOutputStream.open(Native Method)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)
          bq.
          New: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}public class AppTest {
            @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"));
            }
          }
          {quote}

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

          bq. 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
          bq. Caused by: java.io.FileNotFoundException: C:\projects\jenkins-publisher-plugin\.\target\jenkins-for-test.exploding (The system cannot find the path specified)
          bq.
          bq. at java.io.FileOutputStream.open(Native Method)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)
          bq.
          Alex Java made changes -
          Description Original: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}public class AppTest {
            @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"));
            }
          }
          {quote}

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

          bq. 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
          bq. Caused by: java.io.FileNotFoundException: C:\projects\jenkins-publisher-plugin\.\target\jenkins-for-test.exploding (The system cannot find the path specified)
          bq.
          bq. at java.io.FileOutputStream.open(Native Method)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)
          bq.
          New: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}

          public class AppTest {
            @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"));
            }
          }
          {quote}

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

          bq. 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)
          bq.
          bq. at java.io.FileOutputStream.open(Native Method)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)
          bq.
          Alex Java made changes -
          Description Original: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}

          public class AppTest {
            @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"));
            }
          }
          {quote}

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

          bq. 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)
          bq.
          bq. at java.io.FileOutputStream.open(Native Method)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
          bq.
          bq. at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.explode(WarExploder.java:99)
          bq.
          bq. at org.jvnet.hudson.test.WarExploder.<clinit>(WarExploder.java:58)
          bq.
          New: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}

          public class AppTest {
            @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"));
            }
          }
          {quote}

          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)
          Alex Java made changes -
          Description Original: I tried sample code at the top of this page: https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

          {quote}

          public class AppTest {
            @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"));
            }
          }
          {quote}

          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)
          New: 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)
          Oleg Nenashev made changes -
          Component/s New: core [ 15593 ]
          Component/s Original: _test [ 19622 ]
          Labels New: test test-harness
          Oleg Nenashev made changes -
          Assignee Original: Oleg Nenashev [ oleg_nenashev ]
          Daniel Beck made changes -
          Component/s New: gradle-jpi-plugin [ 16321 ]
          Component/s Original: core [ 15593 ]
          Assignee New: Daniel Spilker [ daspilker ]
          Daniel Spilker made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          Alex Java made changes -
          Link New: This issue duplicates JENKINS-26331 [ JENKINS-26331 ]

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

              Created:
              Updated:
              Resolved: