Skip to main content

Cucmber generator

Для формирования .feature файлов на основе html tags. Необходимую информацию для .feature файлов берем из epic/issue GitLab и GitHub.

Установка

Вводим в терминал следующую команду

pip install generator-cucumber

или вносим в requirements.txt

generator-cucumber==<version>

Пример работы generator-cucumber

  1. Создаем epic и добавляем специальные tags (дублирующие ключевые слова языка Gherkin)

<src-1>
<src-1-1>

<scenario>Напишем сценарий</scenario>

<given>Здесь добавим given</given>
<when>Здесь добавим when</when>
<then>Здесь добавим then</then>

<group>

<then>Таблица THEN<groupin> </groupin> </then>

Наименование Что-то
<examples>Первый</examples> 1
<examples>Второй</examples> 2
<examples>Третий</examples> 3

</group>

</src-1-1>
</src-1>

  1. В GitLab Epic будет выглядить следующим образом

Напишем сценарий

Здесь добавим given
Здесь добавим when
Здесь добавим then

Таблица THEN
Наименование Что-то
Первый 1
Второй 2
Третий 3
  1. После установки generator-cucumber создаем тест (например test_example.py)
from generator_cucumber import Generator

Generator.URL_GIT = 'https://gitlab.com/' # url развернутого gitlab
Generator.PRIVATE_TOKEN_GIT = 'gsdff-sdx5DkswkqSDFSSQnVL' #'здесь необходим ваш access token (для примeра)

Generator.create_cucumber(
    group_id=100, # номер группы в которой написан epic
    epi_iid=1, # номер  epic
    name_file='test_lib', # наименование файла .feature (любое удобное)
    scenario_number='src-1-1', # текст к которому относиться тест
    ssl_verify=True # если все ок с ssl, по умолчанию false
)
  1. После запуска теста сформируется .feature файл и папка featurecache для контроля изменений в тексте
# https://gitlab.com/python_epic/test_pr/-/epic/1
# Di
# 2024-08-01T01:48:53.366Z

Feature: Тестируем lib

    Scenario: Напишем сценарий

        Given Здесь добавим given

        When Здесь добавим when

        Then Таблица THEN  "<col_1>", "<col_2>", "<col_3>"
 
            Examples: col_1, col_2, col_3
                | col_1 | col_2 | col_3 |
                | Первый | Второй | Третий |

Html tags

gherkin equivalent HTML equivalent
"and" <and></and>
"background" <background></background>
"but" <but></but>
"examples" <examples></examples>
"feature" <feature></feature>
"given" <given></given>
"scenario" <scenario></scenario>
"scenarioOutline" <scenariooutline></scenariooutline>
"then" <then></then>
"when" <when></when>

Html tags ➕

gherkin equivalent HTML equivalent (tags) Описание
"groupin" <groupin></groupin> Место куда поставиться examples
"scr-1-1" <scr-1-1></scr-1-1> Для ограничения места для генерации (номер условный)

Стуктура проекта

# Проект по генерации .feature
├── 📁 generator_cucumber/
|   ├── 🐍 api_github.py        # для работы с github (не реализован)
|   ├── 🐍 api_gitlab.py        # Для работы с gitlab
|   ├── 🐍 bdd_generator.py     # Для работы с .py и подготовка шаблона bdd
|   ├── 🐍 cache_file.py        # создание файлов cache
|   ├── 🐍 create_file.py       # Обработка файлов cache и .feature
|   ├── 🐍 cucumber_text.py     # Формирование .feature текст
|   └── 🐍 generator.py         # входная точка
└── ... 

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

generator_cucumber-0.0.23.tar.gz (69.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

generator_cucumber-0.0.23-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file generator_cucumber-0.0.23.tar.gz.

File metadata

  • Download URL: generator_cucumber-0.0.23.tar.gz
  • Upload date:
  • Size: 69.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for generator_cucumber-0.0.23.tar.gz
Algorithm Hash digest
SHA256 bcf6aceed560324b6dd69454f79ab28b2e8b9c1c85868088df54d881f7c673e8
MD5 d490fd6bba8281e7e724affb36756402
BLAKE2b-256 8acd520b974df823a6425b1811758830c331f1d37ce166c2921b900d16e63ac3

See more details on using hashes here.

File details

Details for the file generator_cucumber-0.0.23-py3-none-any.whl.

File metadata

File hashes

Hashes for generator_cucumber-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 5358d04ff11de68b86656ad4822baa6e962afa00ab0eb4c88928168cb769905c
MD5 9e333fdcd6affd821d59c5e74ab95d39
BLAKE2b-256 72747f1ea2090b5372bed3797ed6b4c7a2fc36f27e3d70e924b5254068108809

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.23 This release

2 files

0.0.22

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page