JBehave
  1. JBehave
  2. JBEHAVE-157

Steps class can't depend on a library with <scope>test</scope> in pom.xml

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.1
    • Fix Version/s: None
    • Component/s: Maven Plugin
    • Labels:
      None
    • Environment:
      $ mvn -version
      Maven version: 2.0.9
      Java version: 1.5.0_16
      OS name: "mac os x" version: "10.5.6" arch: "i386" Family: "unix"
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      In my Steps implementation, I use an external library. In my pom.xml, this is dependency is declared with <scope>test</scope>. jBehave maven plugin is not able to find this library. Please run the attached project as:

      $ mvn clean integration-test -Dlib.scope=compile
      ...
      [INFO] Running scenario binil.scenarios.MyScenario
      ...
      [INFO] BUILD SUCCESSFUL
      ...

      $ mvn clean integration-test -Dlib.scope=test
      ...
      [INFO] [jbehave:run-scenarios

      {execution: run-scenarios-listed}

      ]
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Failed to instantiate scenario 'binil.scenarios.MyScenario'

      Embedded error: The scenario 'binil.scenarios.MyScenario' could not be instantiated with class loader: [org.jbehave.scenario.ScenarioClassLoader urls=[/Users/binil/work/jbehave-bug-report/target/test-classes/, /Users/binil/work/jbehave-bug-report/target/classes]]
      org/apache/log4j/Logger
      ...
      $

      This forces me to declare the dependency (in my specific case, jetty and dbunit) as <scope>compile</scope> in my pom.xml, which means all users of my project needs to get this library as a transitive dependency. I would like to avoid that.

        Activity

        Mauro Talevi made changes -
        Field Original Value New Value
        Assignee Mauro Talevi [ maurotalevi ]
        Hide
        Mauro Talevi added a comment -

        Just declare the steps dependency at runtime scope and the scenarios will run at test scope without it imposing a transitive compile dependency:

        http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

        The problem here is that you're mixing the Maven unit-test scope with the integration-test one.

        IMO it is highly recommendable that unit-level tests and scenario behaviours should be completely separated. It is recommendable to have the scenarios live in a separate module (in src/main rather than src/test).

        This is also desirable as an integration test will typically exercise the functionality of multiple modules, while the unit tests only the single module.

        Show
        Mauro Talevi added a comment - Just declare the steps dependency at runtime scope and the scenarios will run at test scope without it imposing a transitive compile dependency: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html The problem here is that you're mixing the Maven unit-test scope with the integration-test one. IMO it is highly recommendable that unit-level tests and scenario behaviours should be completely separated. It is recommendable to have the scenarios live in a separate module (in src/main rather than src/test). This is also desirable as an integration test will typically exercise the functionality of multiple modules, while the unit tests only the single module.
        Mauro Talevi made changes -
        Resolution Won't Fix [ 2 ]
        Status Open [ 1 ] Resolved [ 5 ]

          People

          • Assignee:
            Mauro Talevi
            Reporter:
            Binil Thomas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: