Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sw-tester/bdd-transform-values

It helps to substitute tokens on Gherkin feature files from either Yaml or Json
https://github.com/sw-tester/bdd-transform-values

bdd gherkin java qa qa-automation

Last synced: about 10 hours ago
JSON representation

It helps to substitute tokens on Gherkin feature files from either Yaml or Json

Awesome Lists containing this project

README

        

# BDD-Transform-Values

## Introduction
This library when run as a maven plugin will transform values on feature files in Cucumber-JVM based
automation, and in some cases, this helps to substitute values, mostly for the commonly used data from yaml
files.

## Objective

— no hard-coded test data in feature files within automation projects

— auto-generate date values (past or future) to stay relevant before test runs

## Requirement

[Maven](https://maven.apache.org/)

[Cucumber-JVM](https://cucumber.io/docs/installation/java/)

[Jayway's JsonPath()](https://github.com/json-path/JsonPath)

## Installation

Add this block to `pom.xml`


...

io.github.5v1988
bdd-transform-values-maven-plugin
1.0.3



transform-values




...

By default, this plugin will look for substituting values from the file: `token.yaml`.
Optionally, the file with a different name can also be passed as follows:


...

another-file.yaml

...

After adding this plugin dependency on `pom.xml`, along with surefire-plugin, `mvn test` either substitutes values from
yaml file by matching the path or auto-generate like in case of date values. Please also note that
it doesn't modify the original feature files, but the ones in build directory: `target`

## Examples

`token.yaml`

```yaml
test-config:
url: https://test.com
account:
email: [email protected]
password: qa-test123!
name: Tommy
```

```gherkin
Feature: Login feature

@example1
Scenario: To verify that the user logins successfully [without plugin]
Given User opens the app url: "https://test.com"
When User enters account details: "[email protected]" and "qa-test123!"
Then User verifies the name as : "Tommy" and date as "06/26/2023"

@example2
Scenario Outline: To verify that the user logins successfully [with plugin]
Given User opens the app url: "[ type: token, path: test-config.url ]"
When User enters account details: "" and ""
Then User verifies the name as : "" and date as "[ type: date, format: MM/dd/yyyy, delta: 0 ]"

Examples:
| UserName | Password | Name |
| [ type: token, path: account.email ] | [ type: token, path: account.password ] | [ type: token, path: account.name ] |
```

## Explanation

`[ type: token, path: account.name ]` => In this template, Jsonpath `account.name` gets
value `Tommy` from the yaml file

`[ type: date, format: MM/dd/yyyy, delta: -1 ]` => Yesterday's date in `MM/dd/yyyy` format

`[ type: date, format: dd-MM-yyyy, delta: 1 ]` => Tomorrow's date in `dd-MM-yyyy` format

## To-Do

`[ type: random, format: mobile-number ]` => This template returns randomly generated mobile
number. other formats could be last-name, full-name, mobile-number, address-line-1 etc.

## How to help

If you come across an issue while using this plugin, do help to file a bug [here](https://github.com/5v1988/bdd-transform-values/issues)