JBehave
  1. JBehave
  2. JBEHAVE-498

withRelativeDirectory appears to be broken

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 3.x
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Linux. Jdk6
    • Number of attachments :
      0

      Description

      I'm working in a non maven environment. I attempted to set the output directory for reports as follows

      public static class MyReportBuilder extends StoryReporterBuilder {
      public MyReportBuilder()

      { super(); this.withRelativeDirectory("../build/publish/story-reports"); this.withFormats(CONSOLE, HTML, XML); }

      }

      Upon running the JUnits I get the following:

      org.jbehave.core.reporters.FilePrintStreamFactory$PrintStreamCreationFailed: Failed to create print stream for file /home/derek/workspace/smsManagerGit/target/../build/publish/story-reports/BeforeStories.html
      at org.jbehave.core.reporters.FilePrintStreamFactory.createPrintStream(FilePrintStreamFactory.java:39)
      at org.jbehave.core.reporters.Format$4.createStoryReporter(Format.java:43)
      at org.jbehave.core.reporters.StoryReporterBuilder.reporterFor(StoryReporterBuilder.java:310)
      at org.jbehave.core.reporters.StoryReporterBuilder.build(StoryReporterBuilder.java:285)
      at org.jbehave.core.configuration.Configuration.storyReporter(Configuration.java:200)
      at org.jbehave.core.embedder.StoryRunner.runBeforeOrAfterStories(StoryRunner.java:58)
      at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:209)
      at au.com.sensis.wireless.smsmanager.integration.bdd.stories.AnnotatedStoryEmbedder.run(AnnotatedStoryEmbedder.java:48)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
      at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: java.io.FileNotFoundException: /home/derek/workspace/smsManagerGit/target/../build/publish/story-reports/BeforeStories.html (No such file or directory)
      at java.io.FileOutputStream.open(Native Method)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
      at org.jbehave.core.reporters.FilePrintStreamFactory$FilePrintStream.<init>(FilePrintStreamFactory.java:137)
      at org.jbehave.core.reporters.FilePrintStreamFactory.createPrintStream(FilePrintStreamFactory.java:37)
      ... 31 more

      Commenting out the withRelativeDirectory() method and everything works just fine.

        Activity

        Hide
        Mauro Talevi added a comment -

        The relativeDirectory is the directory where the JBehave reporting outputs are written to (defaults to "jbehave"), relative to the story builder code location (defaults to CodeLocations.codeLocationFromPath("target/classes")).

        If you change the relative directory and you're not using the Maven standard layout, you'll probably need to set the code location accordingly, e.g. CodeLocations.codeLocationFromPath("build/publish") and withRelativeDirectory("story-reports"), or combinations thereof.

        You could also try seting the code location from the JUnitStories class: CodeLocations.codeLocationFromClass(this.getClass());

        Show
        Mauro Talevi added a comment - The relativeDirectory is the directory where the JBehave reporting outputs are written to (defaults to "jbehave"), relative to the story builder code location (defaults to CodeLocations.codeLocationFromPath("target/classes")). If you change the relative directory and you're not using the Maven standard layout, you'll probably need to set the code location accordingly, e.g. CodeLocations.codeLocationFromPath("build/publish") and withRelativeDirectory("story-reports"), or combinations thereof. You could also try seting the code location from the JUnitStories class: CodeLocations.codeLocationFromClass(this.getClass());
        Hide
        Derek Clarkson added a comment -

        Thanks for getting back to me so fast.

        I've now tried:

        this.withCodeLocation(CodeLocations.codeLocationFromPath("build/publish"));
        this.withRelativeDirectory("story-reports");

        Which almost works. It creates the files in build/story-reports. I don't know why it's ignoring the publish directory.

        Just done some experimenting. It seems that you have to put in one more directory level than you want to use. ie. build/publish maps to build, build/publish/x maps to build/publish

        So there still appears to be a bug in that it is not correctly assembling the output path from the code location.

        Secondly I'd like to request that StoryReportBuilder.withCodeLocation(...) be renamed to StoryReportBuilder.withReportLocation(...). Calling it withCodeLocation is anything but intuitive and the whole reason I wasted several hours trying to figure out how to do this before posting the bug report. In addition, I don't see the need for a separation of the location and relative directory. It just adds to the confusion.

        Show
        Derek Clarkson added a comment - Thanks for getting back to me so fast. I've now tried: this.withCodeLocation(CodeLocations.codeLocationFromPath("build/publish")); this.withRelativeDirectory("story-reports"); Which almost works. It creates the files in build/story-reports. I don't know why it's ignoring the publish directory. Just done some experimenting. It seems that you have to put in one more directory level than you want to use. ie. build/publish maps to build, build/publish/x maps to build/publish So there still appears to be a bug in that it is not correctly assembling the output path from the code location. Secondly I'd like to request that StoryReportBuilder.withCodeLocation(...) be renamed to StoryReportBuilder.withReportLocation(...). Calling it withCodeLocation is anything but intuitive and the whole reason I wasted several hours trying to figure out how to do this before posting the bug report. In addition, I don't see the need for a separation of the location and relative directory. It just adds to the confusion.
        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 3.4 [ 17278 ]
        Affects Version/s web-3.3 [ 17272 ]
        Hide
        Mauro Talevi added a comment -

        Derek, code location is not the same thing as report location. The code location is used for other purposes and allows us to find the URL where the compiled code is. The reports live in a relative directory of the code location.

        Could you see if you can reproduce your behaviour in a unit test?

        Show
        Mauro Talevi added a comment - Derek, code location is not the same thing as report location. The code location is used for other purposes and allows us to find the URL where the compiled code is. The reports live in a relative directory of the code location. Could you see if you can reproduce your behaviour in a unit test?
        Mauro Talevi made changes -
        Fix Version/s 3.x [ 16979 ]
        Fix Version/s 3.4 [ 17278 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Derek Clarkson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: