12

I'm just getting started learning jBehave and Maven (in Eclipse). I've installed JBehave Eclipse 1.0.0.20140605-071 and added it to my Maven dependencies - the relevant bit of pom.xml looks like (edited after reply):

<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.wmaop</groupId>
    <artifactId>wm-jbehave</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
  </dependency>
</dependencies>
<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

That gives me an error:

missing artefact org.wmaop:wm-jbehave.jar:1.0.0

If I try to build I get the error:

Failure to find org.wmaop:wm-jbehave:jar:1.0.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

The "Creating a test project with Maven" tutorial says "If errors exist in the project, open the pom.xml file to check if the wm-jbehave dependency is not found. Verify that your Designer has access to the internet in order to retrieve the jar dependencies", but I don't know what that means - the computer certainly has access to the Internet - I'm typing this on it.

How do I resolve this error?

digitig
  • 1,989
  • 3
  • 25
  • 45
  • Do you only need to learn [JBehave](http://jbehave.org/) in Eclipse ? Or do you need to use [testing tools for the webMethods Integration Suite WM-AOP](https://github.com/wmaop) to run JBehave stories ? All your problems emerge from missing WM-AOP libraries, mayby it would be better to start learning JBehave alone without additional complexity of WM-AOM framework? JBehave does not need WM_AOM, it can run on many frameworks, even without any framework simply from the command line. – krokodilko Sep 12 '17 at 06:27
  • I'm used to BDD using Cucumber and Ruby. Basically, I want a similar environment for Java, and JBehave seems to be the most likely candidate (and Eclipse is my preferred IDE). My problem is simply that I can't get the installation instructions to work - I'm not even sure where WM-AOP fits in, except that it's mentioned in the error message I get. – digitig Sep 14 '17 at 21:19

5 Answers5

6

I'm not even sure where WM-AOP fits in, except that it's mentioned in the error message I get.

It seems you don't even know what WM-AOP is :)
This tutorial (from your question) shows how to enable and run JBehave together with their webMethods Designer.
In other words - this is a standalone product (integration server) that uses another standalone project JBehave
In order to run this tutorial, you need first to download, install and configure webMethods Designer & Integration Server Flow services., and then create a project that uses this server and JBehave to run tests on this server.


But you dont't need this stuff to learn JBehave. JBehave is a standalone product, which can be run in many environments, even in a pure Java (JDK).

Just follow the steps below


1. In Eclipse - click New/Maven project enter image description here


2. On the following dialog Click Next

enter image description here


3. On the next page type in "jbehave-simple-archetype", choose version 4.1 and click next
Note - don't use the latest version 4.1.1 because it doesn't work (there is a bug which will be resolved in upcoming version 4.1.2 in 1-2 weeks enter image description here


4. Enter group-id and artifact-id of your project and click Finish enter image description here


That's all - your JBehave project is ready.


In src/main/resources/org/example/myJbehave/stories/ you will find my.story with an example story:

Scenario: A scenario with some pending steps

Given I am a pending step
And I am still pending step
When a good soul will implement me
Then I shall be happy

In src/main/java/org/example/myJbehave/steps/ you will find MySteps.java class. Modify it in this way:

import org.jbehave.core.annotations.Alias;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;

public class MySteps {

    @Given("I am a pending step")
    @Alias("I am still pending step")
    public void given_i_am_pending_step() {

        System.out.println("Tihis is implementation of GIVEN");
    }

    @When("a good soul will implement me")
    public void when_a_good_soul_will_implement_me() {
        System.out.println("Tihis is implementation of WHEN");
    }

    @Then("I shall be happy")
    public void then_i_shall_be_happy() {
        System.out.println("Tihis is implementation of THEN");
    }
}

In /src/main/java/org/example/myJbehave/ you will find MyStories.java
This class contains configuration & bootstrap code
Right click on it using a mouse, then choose "Run as / JUnit test" , and the story will be executed enter image description here

enter image description here


You will see in the console tab a result like this:

Processing system properties {}
Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true,verboseFailures=false,verboseFiltering=false,storyTimeouts=60,threads=2,failOnStoryTimeout=false]

(BeforeStories)
Running story org/example/myJbehave/stories/my.story
Tihis is implementation of GIVEN
Tihis is implementation of GIVEN
Tihis is implementation of WHEN
Tihis is implementation of THEN

(org/example/myJbehave/stories/my.story)
Scenario: A scenario with some pending steps
Given I am a pending step
And I am still pending step
When a good soul will implement me
Then I shall be happy



(AfterStories)
Generating reports view to 'C:\Users\irko\eclipse-workspace1\myJbehave\target\jbehave' using formats '[stats, console, txt, html, xml]' and view properties '{navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, reports=ftl/jbehave-reports.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl, decorated=ftl/jbehave-report-decorated.ftl, maps=ftl/jbehave-maps.ftl}'
Reports view generated with 2 stories (of which 0 pending) containing 1 scenarios (of which 0 pending)

Note: follow these steps to install JBehave Eclipse plugin which contains usefull *.story editor.

krokodilko
  • 35,300
  • 7
  • 55
  • 79
  • No, that fails at step 3. That page doesn't show any archetypes, and when I enter jbehave-simple-archetype, Eclipse crashes with an out of memory error - Java heap space. I've tried starting Eclipse with -vmargs -Xmx1000M but I still get the same error. – digitig Sep 29 '17 at 22:49
  • Further to that, following the instructions at https://howtodoinjava.com/tools/eclipse/how-to-import-maven-remote-archetype-catalogs-in-eclipse/ to get local copies of the archetypes. the error changes to "No marketplace entries found to handle jbehave-maven-plugin:4.1:unpack-view-resources in Eclipse. Please see Help for more information." I can't find any relevant help. – digitig Sep 29 '17 at 23:05
4

As far as I can see it is not on Maven central repo so no wodner, but It is available on GitHub so lets fetch it from ther using JitPack

Add this to your POM

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
Antoniossss
  • 31,590
  • 6
  • 57
  • 99
  • Just adding that doesn't do it, nor does updating the project after adding it, nor building. Is there something I need to do to force the fetch? – digitig Sep 08 '17 at 22:08
  • Looks like you will have to build it yourself then. https://github.com/wmaop/wm-jbehave/releases. Just remember to include parent pom as well. – Antoniossss Sep 08 '17 at 22:46
  • How do I include the parent pom? This is my first day of using Maven... – digitig Sep 08 '17 at 23:58
3

try this repo instead: https://repo.azure.jenkins.io/public.

Or build the project in local:

git clone https://github.com/wmaop/wm-jbehave.git --branch  wm-jbehave-1.0.0
cd wm-jbehave
mvn clean install
sab
  • 4,352
  • 7
  • 36
  • 60
  • Adding that repo made no difference. Following the local build instructions gave me the familiar error: [ERROR] The project org.wmaop:wm-jbehave:1.0.0 (C:\Users\digit\Desktop\jbehave\wm-jbehave\pom.xml) has 1 error [ERROR] Non-resolvable parent POM for org.wmaop:wm-jbehave:1.0.0: Failure to find org.wmaop:wm-parent:pom:1.0.5 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 8, column 10 – digitig Sep 14 '17 at 21:32
  • do you want to stay in the 1.0.0 version of vm jbehaven or you are ok to try another version? if so, try another version: the 1.1.0 seems easier to find. – sab Sep 15 '17 at 16:35
1

As per the error posted:

"Failure to find org.wmaop:wm-jbehave:jar:1.0.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]"

It seems project requires forced maven update to resolve missing artefacts. Simply Right-click on your project(s) --> Maven --> Update Project. Make sure "Force Update of Snapshots/Releases" is checked.

saurabh2208
  • 72
  • 1
  • 1
  • 7
0

Below maven dependency and repository entries worked for compilation of a sample maven project based on tutorial link in your question.

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.wmaop</groupId>
        <artifactId>wm-jbehave</artifactId>
        <version>1.1.1</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>com.entrust</groupId>
                <artifactId>toolkit</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.softwareag.webmethods</groupId>
                <artifactId>wm-isserver</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.softwareag.webmethods</groupId>
                <artifactId>wm-isclient</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>bintray.io</id>
        <url>https://dl.bintray.com/wmaop/maven</url>
    </repository>
</repositories>

Note that the tutorial also requires additional set up for running HelloWorld story.

It might be easier to follow the answer provided by @krokodilko using simple jbehave maven archetype.

Ravi
  • 21
  • 4