JBehave
  1. JBehave
  2. JBEHAVE-504

Ant task RunStoriesWithAnnotatedEmbedderRunner not passing system properties to embedder

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.3.2
    • Fix Version/s: 3.4
    • Component/s: Ant Tasks
    • Labels:
      None
    • Environment:
      Ant
    • Number of attachments :
      0

      Description

      I'm trying to run JBehave from Ant using the following ant code:

       
      <taskdef name="runStoriesWithAnnotatedEmbedderRunner"
          classname="org.jbehave.ant.RunStoriesWithAnnotatedEmbedderRunner" 
          classpathref="integration.tests.classpath" />
      
      <runStoriesWithAnnotatedEmbedderRunner includes="**/*StoryEmbedder.java"
          sourceDirectory="src/integration"
          systemProperties="java.awt.headless=true,web.project.dir=${build.integration.web.dir}" 
          ignoreFailureInStories="true" 
          ignoreFailureInView="false" 
          generateViewAfterStories="true" />
      

      At the momment I'm getting a class not found which the story embedder I've written starts up (doesn't happen from a junit run inside eclipse!).

      I think that it's running from the default directory because it appears that the systemProperties are not making it through to the embedder. Here's the log showing the startup:

      run-bdd-tests:
      [runStoriesWithAnnotatedEmbedderRunner] Running stories with annotated embedder org.jbehave.core.junit.AnnotatedEmbedderRunner
      [runStoriesWithAnnotatedEmbedderRunner] Found class names : [au.com.sensis.wireless.smsmanager.integration.bdd.stories.AnnotatedStoryEmbedder]
      [runStoriesWithAnnotatedEmbedderRunner] 2011-05-03 16:12:21,042 DEBUG [runStoriesWithAnnotatedEmbedderRunner] Processing system properties {}
      

      As you can see it's reporting no properties passed. Digging into the Ant task code supports that the properties are not getting through, but from what I can see in the source there is no obvious reason. Possibly the code that loads the properties has a bug and is throwing an exception because it's try-catch silently swallows any errors.

        Activity

        Mauro Talevi made changes -
        Field Original Value New Value
        Affects Version/s 3.3.2 [ 17308 ]
        Affects Version/s web-3.2 [ 16758 ]
        Description I'm trying to run JBehave from Ant using the following ant code:

        {code:ant}
        <taskdef name="runStoriesWithAnnotatedEmbedderRunner"
            classname="org.jbehave.ant.RunStoriesWithAnnotatedEmbedderRunner"
            classpathref="integration.tests.classpath" />

        <runStoriesWithAnnotatedEmbedderRunner includes="**/*StoryEmbedder.java"
            sourceDirectory="src/integration"
            systemProperties="java.awt.headless=true,web.project.dir=${build.integration.web.dir}"
            ignoreFailureInStories="true"
            ignoreFailureInView="false"
            generateViewAfterStories="true" />
        {code}

        At the momment I'm getting a class not found which the story embedder I've written starts up (doesn't happen from a junit run inside eclipse!).

        I think that it's running from the default directory because it appears that the systemProperties are not making it through to the embedder. Here's the log showing the startup:

        {code}
        run-bdd-tests:
        [runStoriesWithAnnotatedEmbedderRunner] Running stories with annotated embedder org.jbehave.core.junit.AnnotatedEmbedderRunner
        [runStoriesWithAnnotatedEmbedderRunner] Found class names : [au.com.sensis.wireless.smsmanager.integration.bdd.stories.AnnotatedStoryEmbedder]
        [runStoriesWithAnnotatedEmbedderRunner] 2011-05-03 16:12:21,042 DEBUG [runStoriesWithAnnotatedEmbedderRunner] Processing system properties {}
        {code}

        As you can see it's reporting no properties passed. Digging into the Ant task code supports that the properties are not getting through, but from what I can see in the source there is no obvious reason. Possibly the code that loads the properties has a bug and is throwing an exception because it's try-catch silently swallows any errors.
        I'm trying to run JBehave from Ant using the following ant code:

        {code:xml}
        <taskdef name="runStoriesWithAnnotatedEmbedderRunner"
            classname="org.jbehave.ant.RunStoriesWithAnnotatedEmbedderRunner"
            classpathref="integration.tests.classpath" />

        <runStoriesWithAnnotatedEmbedderRunner includes="**/*StoryEmbedder.java"
            sourceDirectory="src/integration"
            systemProperties="java.awt.headless=true,web.project.dir=${build.integration.web.dir}"
            ignoreFailureInStories="true"
            ignoreFailureInView="false"
            generateViewAfterStories="true" />
        {code}

        At the momment I'm getting a class not found which the story embedder I've written starts up (doesn't happen from a junit run inside eclipse!).

        I think that it's running from the default directory because it appears that the systemProperties are not making it through to the embedder. Here's the log showing the startup:

        {code}
        run-bdd-tests:
        [runStoriesWithAnnotatedEmbedderRunner] Running stories with annotated embedder org.jbehave.core.junit.AnnotatedEmbedderRunner
        [runStoriesWithAnnotatedEmbedderRunner] Found class names : [au.com.sensis.wireless.smsmanager.integration.bdd.stories.AnnotatedStoryEmbedder]
        [runStoriesWithAnnotatedEmbedderRunner] 2011-05-03 16:12:21,042 DEBUG [runStoriesWithAnnotatedEmbedderRunner] Processing system properties {}
        {code}

        As you can see it's reporting no properties passed. Digging into the Ant task code supports that the properties are not getting through, but from what I can see in the source there is no obvious reason. Possibly the code that loads the properties has a bug and is throwing an exception because it's try-catch silently swallows any errors.
        Hide
        Mauro Talevi added a comment -

        Derek, system properties (or other configurable properties) are all ignored when running with AnnotatedEmbedderRunner, which by design gets the Embedder configuration from the annotation @UsingEmbedder.

        The system properties were missing in the @UsingEmbedder (now fixed in JBEHAVE-506).

        If you want to specify your configuration via Ant task, you can use a ConfigurableEmbedder instance, e.g. JUnitStories.

        Show
        Mauro Talevi added a comment - Derek, system properties (or other configurable properties) are all ignored when running with AnnotatedEmbedderRunner, which by design gets the Embedder configuration from the annotation @UsingEmbedder. The system properties were missing in the @UsingEmbedder (now fixed in JBEHAVE-506 ). If you want to specify your configuration via Ant task, you can use a ConfigurableEmbedder instance, e.g. JUnitStories.
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 3.4 [ 17278 ]
        Resolution Won't Fix [ 2 ]
        Hide
        Derek Clarkson added a comment -

        Hmm, thats an issue for my code. I'm doing things with POJOs and annotations so I'm not sure how I could setup a ConfigurableEmbedder without re-writing everything.

        The reason I was trying to set a property was that one of the classes used in the test code needs to be passed a directory. Presently it's getting this from a system property. It has a default that works fine inside eclipse, but when running from ant I need to give it a different directory by setting a system property.

        Show
        Derek Clarkson added a comment - Hmm, thats an issue for my code. I'm doing things with POJOs and annotations so I'm not sure how I could setup a ConfigurableEmbedder without re-writing everything. The reason I was trying to set a property was that one of the classes used in the test code needs to be passed a directory. Presently it's getting this from a system property. It has a default that works fine inside eclipse, but when running from ant I need to give it a different directory by setting a system property.
        Hide
        Brian Repko added a comment -

        Derek, I would look at the Spring Security example. That uses regular old junit to run the jbehave stories. That allows for both classpath-ing as well as inserting system properties for coverage (yes, you can do coverage on your functional tests).

        Show
        Brian Repko added a comment - Derek, I would look at the Spring Security example. That uses regular old junit to run the jbehave stories. That allows for both classpath-ing as well as inserting system properties for coverage (yes, you can do coverage on your functional tests).
        Hide
        Derek Clarkson added a comment -

        @Brian - Thanks. Thats exactly what I ended up doing.

        Show
        Derek Clarkson added a comment - @Brian - Thanks. Thats exactly what I ended up doing.
        Hide
        Mauro Talevi added a comment -

        You can also specify them programmatically via Java system properties in your custom Embedder instance (configured via @UsingEmbedder). I've updated TraderAnnotatedEmbedder example to show this in action (works with latest snapshot).

        Note though that if systemProperties are also specified in the @UsingEmbedder they will override what you specify in your embedder, just like Ant/Maven configuration override what is configured programmatically.

        Show
        Mauro Talevi added a comment - You can also specify them programmatically via Java system properties in your custom Embedder instance (configured via @UsingEmbedder). I've updated TraderAnnotatedEmbedder example to show this in action (works with latest snapshot). Note though that if systemProperties are also specified in the @UsingEmbedder they will override what you specify in your embedder, just like Ant/Maven configuration override what is configured programmatically.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: