UD BDD Core library

Core library used by the JUnit 5 based UD BDD library

Лицензия

Лицензия

Группа

Группа

io.github.udaychandra.bdd
Идентификатор

Идентификатор

bdd-core
Последняя версия

Последняя версия

0.1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

UD BDD Core library
Core library used by the JUnit 5 based UD BDD library
Ссылка на сайт

Ссылка на сайт

https://github.com/udaychandra/bdd
Система контроля версий

Система контроля версий

https://github.com/udaychandra/bdd

Скачать bdd-core

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.udaychandra.bdd/bdd-core/ -->
<dependency>
    <groupId>io.github.udaychandra.bdd</groupId>
    <artifactId>bdd-core</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.udaychandra.bdd/bdd-core/
implementation 'io.github.udaychandra.bdd:bdd-core:0.1.1'
// https://jarcasting.com/artifacts/io.github.udaychandra.bdd/bdd-core/
implementation ("io.github.udaychandra.bdd:bdd-core:0.1.1")
'io.github.udaychandra.bdd:bdd-core:jar:0.1.1'
<dependency org="io.github.udaychandra.bdd" name="bdd-core" rev="0.1.1">
  <artifact name="bdd-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.udaychandra.bdd', module='bdd-core', version='0.1.1')
)
libraryDependencies += "io.github.udaychandra.bdd" % "bdd-core" % "0.1.1"
[io.github.udaychandra.bdd/bdd-core "0.1.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

BDD

A BDD library that provides a custom extension based on JUnit 5 Jupiter Extension Model. This library can be used to create and run stories and behaviors a.k.a BDD specification tests.

Basic Usage

You need to add JUnit 5 dependencies before using this library. If you are using a build tool like Maven or Gradle, add the following dependency after setting-up JUnit:

  • Maven pom.xml

     <dependency>
       <groupId>io.github.udaychandra.bdd</groupId>
       <artifactId>bdd-junit</artifactId>
       <version>0.1.0</version>
       <scope>test</scope>
     </dependency>
  • Gradle build.gradle

     dependencies {
       testImplementation 'io.github.udaychandra.bdd:bdd-junit:0.1.0'
     }

You can now write stories using @Story and @Scenario annotations provided by this library. Here's an example:

import io.github.udaychandra.bdd.ext.Scenario;
import io.github.udaychandra.bdd.ext.Story;

@Story(name = "Returns go back to the stockpile",
        description = "As a store owner, in order to keep track of stock," +
                " I want to add items back to stock when they're returned.")
public class StoreFrontTest {

    @Scenario("Refunded items should be returned to stock")
    public void refundAndRestock(Scene scene) {
        scene.
            given("that a customer previously bought a black sweater from me",
                    () -> scene.put("store", new StoreFront(0, 4).buyBlack(1))).

            and("I have three black sweaters in stock",
                    () -> assertEquals(3, scene.<StoreFront>get("store").getBlacks(),
                            "Store should carry 3 black sweaters")).

            when("the customer returns the black sweater for a refund",
                    () -> scene.<StoreFront>get("store").refundBlack(1)).

            then("I should have four black sweaters in stock",
                    () -> assertEquals(4, scene.<StoreFront>get("store").getBlacks(),
                            "Store should carry 4 black sweaters")).
            run();
    }
}

The "Scene" object injected into each test method can be used to store and retrieve arbitrary objects.

When you run these stories (tests), text reports like the one shown below are generated:

STORY: Returns go back to the stockpile

As a store owner, in order to keep track of stock, I want to add items back to stock when they're returned.

SCENARIO: Refunded items should be returned to stock
   GIVEN that a customer previously bought a black sweater from me
     AND I have three black sweaters in stock
    WHEN the customer returns the black sweater for a refund
    THEN I should have four black sweaters in stock

You will find the text reports in a folder named "bdd-reports" located under your test classes build folder.

Development

This is a community project. All contributions are welcome.

To start contributing, do the following:

  • Install JDK 8+
  • Fork or clone the source code
  • Run the build using the gradle wrapper
gradlew clean build

You can read this InfoQ article for more insights.

License

Apache License 2.0

Версии библиотеки

Версия
0.1.1
0.1.0