gpt4 book ai didi

java - Maven 看不到 jBehave

转载 作者:搜寻专家 更新时间:2023-10-30 21:06:43 24 4
gpt4 key购买 nike

我刚刚开始学习 jBehave 和 Maven(在 Eclipse 中)。我已经安装了 JBehave Eclipse 1.0.0.20140605-071 并将其添加到我的 Maven 依赖项中 - pom.xml 的相关位看起来像(回复后编辑):

<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>

这给了我一个错误:

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

如果我尝试构建我会收到错误:

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]

“使用 Maven 创建测试项目”tutorial说“如果项目中存在错误,请打开 pom.xml 文件以检查是否找不到 wm-jbehave 依赖项。验证您的设计器是否可以访问互联网以检索 jar 依赖项”,但我没有知道那是什么意思 - 计算机 当然可以访问 Internet - 我正在上面打字。

如何解决此错误?

最佳答案

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

看来你连WM-AOP是什么都不知道:)
tutorial (根据您的问题)展示了如何启用和运行 JBehave 及其 webMethods Designer .
换句话说 - 这是一个使用另一个独立项目的独立产品(集成服务器)JBehave
为了运行本教程,您首先需要 download, install and configure webMethods Designer & Integration Server Flow services. ,然后创建一个项目,使用此服务器和 JBehave 在此服务器上运行测试。


但是您不需要这些东西来学习 JBehave。 JBehave 是一个独立的产品,可以在许多环境中运行,甚至可以在纯 Java (JDK) 中运行。

只需按照以下步骤操作即可


<强>1。在 Eclipse 中 - 单击新建/Maven 项目 enter image description here


<强>2。在以下对话框中单击下一步

enter image description here


<强>3。在下一页输入“jbehave-simple-archetype”,选择版本 4.1 并单击下一步
注意 - 不要使用最新版本 4.1.1,因为它不起作用(有一个错误将在 1-2 周内在即将发布的 4.1.2 版本中解决 enter image description here


<强>4。输入你项目的group-id和artifact-id,点击Finish enter image description here


就这样 - 您的 JBehave 项目已准备就绪。


src/main/resources/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

src/main/java/org/example/myJbehave/steps/ 中,您会找到 MySteps.java 类。修改为:

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");
}
}

/src/main/java/org/example/myJbehave/ 你会找到 MyStories.java
此类包含配置和引导代码
用鼠标右键单击它,然后选择“Run as/JUnit test”,故事将被执行 enter image description here

enter image description here


您将在控制台选项卡中看到如下结果:

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)

注:关注these steps安装包含有用的 *.story 编辑器的 JBehave Eclipse 插件。

关于java - Maven 看不到 jBehave,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46124046/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com