English 中文(简体)
与网络驱动人API(JBEWE+Webdriver)一起实施BDD
原标题:Implementing BDD with webdriver API (JBehave+Webdriver)

I m trying to enhance my Webdriver script by implementing a BDD framework. I came to know about JBehave (JBehave+Webdriver) but before going ahead with this I have my concern over how much java code implementation is needed because I m mainly into automation testing. As per my perception JBehave works in three steps:

  1. Adding Story files
  2. Implementing the story files into Java (I m having problem with this step)
  3. Implementing Webdriver calls.

使用这个方法, 如果我有用户故事, 例如注册处在应用程序中, 那么:

  • Implement User Story
  • Implementation in java- Implement the complete authentication logic in Java
  • Implementing webdriver- Automate the user actions

另一个例子 : 我有一个用户故事, 执行特定的工作流程 & amp; 需要在 5-6 页上进行一系列操作, 然后我需要执行/ 模拟 java 代码 。

这是JBEBEWEWE的工作方式吗?还有别的选择吗?

问题回答

JBEWA的五步概览:

  1. Write story (Plain text)
  2. Map steps to Java method (POJO)
  3. Configure stories (only once)
  4. Run stories (with any of: Ant, Maven, JUnit, Eclipse, IntelliJ)
  5. View Reports (HTML)

You can visit for details of jbehave: http://jbehave.org/

You can visit the following for tutorial example: https://github.com/jbehave/jbehave-tutorial

JBEWAWE的工作方式如下:

  1. 写一个描述系统某种理想行为的故事。 这个故事必须按照 < a href=> http://jbewhere.org/ reference/stable/ grammar.html" rel="nofollow" > JBehaves DSL 来写。 故事基本上描述了一个 Give/ When/ then 流中的一系列步骤 。

  2. 执行 pava 代码中的 GED/ 时间/ 时间/ 之后步骤, 包括针对 Webdriver API 写入代码, 以便与测试中的应用程序互动 。

  3. 运行故事并分析结果。 它要么通过,要么失败。

目前我正在写一篇相当详细的博客文章,

jbehave works in one way and does not rely on presence or absence of webdriver if you want to get how-to "in one page" you can look here

Java BDD框架http://java.dzone.com/articles/brief-compararison-bdd - 对我来说,JBeave和Cucumber是最好的选择,因为拥有大型和活跃的社区。

如果您在“ 纯” Java 中执行故事文件有困难, 那么您应该给 < a href=" "http://paulcwarren.github. io/ ginkgo4j/" rel=" nofollow noreferrer" > Ginkgo4j a try. 这是一个 Java Port of RSpec, 允许您在 Java 中测试 RSpec 。

在您的 POM 中添加此依赖关系 :

    <dependency>
        <groupId>com.github.paulcwarren</groupId>
        <artifactId>ginkgo4j</artifactId>
        <version>1.0.9</version>
        <scope>test</scope>
    </dependency>

创建 JUM 测试大小写, 指定 Ginkgo4jRunner 跑者 :

@RunWith(Ginkgo4jRunner.class)
@Ginkgo4jConfiguration(threads = 1)
public class MyTest {
  {
    Describe("ClassUnderTest", () -> {
      Context("#Method", () -> {
        BeforeEach(() -> {
          // before test logic          
        }); 
        JustBeforeEach(() -> {
          ClassUnderTest.Method();          
        }); 
        Context("given a context", () -> {
          It("should do something", () -> {
            // assertions
          });
        });
        Context("given a different context", () -> {
          It("should do something else", () -> {
            // assertions
          });
        });
        AfterEach(() -> {
          // after test logic
        });
      });
    }); 
  }
}




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签