-
Uruchom
Terminal
i zainstaluj wymagane pakiety oraz Atom:sudo apt-get install python3-venv python3-pip -y sudo snap install atom --classic mkdir -p workspace cd workspace # zauważ kropka atom .
-
Zainstaluj następujące pluginy w Atomie (Edit->Preferences):
cucumber
platformio-ide-terminal
-
Utwórz następujące drzewo katalogów oraz jeden plik
example.feature
:workspace/ \- example/ \- features/ |- steps/ \- example.feature
-
Napisz swój pierwszy opis zachowania dla twojej funkcjonalności:
Feature: Healthy food Scenario: eating Given there were 5 cucumbers When I eat 3 cucumbers Then I should have 2 cucumbers
-
W terminalu z poziomu Atoma (Packages -> platformio-ide-terminal-> Toggle) uruchom:
python3 -m venv venv source venv/bin/activate pip install -U behave cd example/ behave -q
-
Zaimplementujmy teraz nasze kroki
steps/step_food.py
:from behave import given, when, then, step @given("there were 5 cucumbers") def step_cucumber(context): pass @when("I eat 3 cucumbers") def step_eating(context): pass @then("I should have 2 cucumbers") def step_after(context): pass
W terminalu:
behave
-
Na zasadzie analogi utwórz drugi scenariusz w
example.features
. Skorzystaj z:behave -q
dla walidacji gherkin, aby zobaczyć czy nie popełniłaś/popełniłeś błędów,behave
, jeśli dodałaś/dodałeś implementacjie w Pythonie.