Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit abf6bd8

Browse files
committed
first commit
0 parents  commit abf6bd8

16 files changed

+1696
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directory
7+
node_modules
8+
9+
# Optional npm cache directory
10+
.npm
11+
12+
# cucumber result output file
13+
messages.ndjson

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 12.19.1

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Coffee Machine
2+
3+
This is an example repository with some Gherkin feature files.
4+
5+
Imagine we have built a coffee machine for our office, with automated tests using Cucumber.
6+
7+
8+
## Expose on CucumberStudio
9+
10+
You can use [CucumberStudio](https://cucumber.io/tools/cucumberstudio/) "BDD with Cucumber project" to expose the features of this repository and their execution:
11+
12+
1. Display the feature files from this repository in CucumberStudio
13+
- Fork this repository in a place you own in your favorite git service
14+
- In CucumberStudio, create a new "BDD with Cucumber" project
15+
- Connect the repository you have forked
16+
- You now have your features nicely exposed on CucumberStudio
17+
18+
Congrats! 🎉
19+
20+
2. Push execution results to CucumberStudio
21+
- Ensure you have nodejs and npm installed
22+
- Run `npm install` to install the libraries (which includes [cucumber-js](https://github.com/cucumber/cucumber-js))
23+
- Execute the feature files with Cucumber by running `node_modules/.bin/cucumber-js`. All test pass.
24+
25+
- Generate results in a format that CucumberStudio understands
26+
27+
When the features are executed the results must be stored in a file. This file must be in `message` format. Not `junit xml` or `json`.
28+
29+
The command line option `--format=message:messages.ndjson` will output execution results in the `message` format, and store them in the file `messages.ndjson`. This is the final command to run:
30+
31+
node_modules/.bin/cucumber-js --format=message:messages.ndjson
32+
33+
Note: you can also run `npm run test` which does the same, as defined in `package.json`.
34+
35+
- Push the results to CucumberStudio
36+
37+
In CucumberStudio, in the settings there is the command line to use to push results. This command line looks something like this:
38+
39+
curl -X POST \
40+
https://studio.cucumber.io/cucumber_project/results \
41+
-F messages=@<path to your result file> \
42+
-H "project-access-token: <your-project-access-token>" \
43+
-H "provider: github" \
44+
-H "repo: <repository_name>" \
45+
-H "branch: main" \
46+
-H "revision: <commit_hash>"
47+
48+
This command is defined in `package.json` as a script. Run `npm run push-results` to run it. You will need to define some environment variables to properly fill in the necessary information:
49+
- `PROJECT_ACCESS_TOKEN`: the unique access token relative to your project
50+
- `REPOSITORY_NAME`: the repository name, like `cucumber/coffee-machine-javascript`
51+
- `COMMIT_HASH`: the git commit hash referring the version actually tested
52+
53+
Command is:
54+
55+
export PROJECT_ACCESS_TOKEN=abcd1234
56+
export REPOSITORY_NAME=yourGitHubName/coffee-machine-javascript
57+
export COMMIT_HASH=$(git rev-parse HEAD)
58+
npm run push-results
59+
60+
- You should see the results being displayed in CucumberStudio.
61+
62+
Congrats! 🎉

features/Bad_usage.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Bad usage
2+
As a lazy coffee user
3+
I can ignore the message displayed by the machine
4+
So I can have coffee and let other people have to clean after me
5+
6+
Scenario: Full grounds does not block coffee
7+
# You keep getting coffee even if the "Empty grounds" message is displayed. That said it's not a fantastic idea, you'll get ground everywhere when you'll decide to empty it.
8+
Given the coffee machine is started
9+
And I handle everything except the grounds
10+
When I take "50" coffees
11+
Then message "Empty grounds" should be displayed
12+
And coffee should be served

features/Can_be_configured.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Feature: Can be configured
2+
As this is a high quality product
3+
It is possible to configure it
4+
In order to get the best possible coffees
5+
6+
Scenario: Display settings
7+
Given the coffee machine is started
8+
When I switch to settings mode
9+
Then displayed message is:
10+
"""
11+
Settings:
12+
- 1: water hardness
13+
- 2: grinder
14+
"""
15+
16+
Scenario: Default settings
17+
Given the coffee machine is started
18+
When I switch to settings mode
19+
Then settings should be:
20+
| water hardness | 2 |
21+
| grinder | medium |

features/Display_errors/Beans.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Feature: Beans
2+
As a coffee lover
3+
I have to put fresh beans from time to time
4+
So I can have coffee when I need it
5+
6+
Background:
7+
Given the coffee machine is started
8+
And I handle everything except the beans
9+
10+
Scenario: Message "Fill beans" is displayed after 38 coffees are taken
11+
When I take "38" coffees
12+
Then message "Fill beans" should be displayed
13+
14+
Scenario: It is possible to take 40 coffees before there is really no more beans
15+
Given I take "40" coffees
16+
Then coffee should be served
17+
When I take a coffee
18+
Then coffee should not be served
19+
And message "Fill beans" should be displayed
20+
21+
Scenario: After adding beans, the message "Fill beans" disappears
22+
Given I take "40" coffees
23+
When I fill the beans tank
24+
Then message "Ready" should be displayed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Feature: Grounds
2+
As a coffee lover
3+
I have to empty the grounds
4+
So I don't end up with a total mess around the coffee machine
5+
6+
Background:
7+
Given the coffee machine is started
8+
And I handle everything except the grounds
9+
10+
Scenario: Message "Empty grounds" is displayed after 30 coffees are taken
11+
When I take "30" coffees
12+
Then message "Empty grounds" should be displayed
13+
14+
Scenario: When the grounds are emptied, message is removed
15+
Given I take "30" coffees
16+
When I empty the coffee grounds
17+
Then message "Ready" should be displayed

features/Display_errors/Water.feature

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Feature: Water
2+
As a coffee lover
3+
I have to handle the water tank
4+
So I can have coffee when I need it
5+
6+
Background:
7+
Given the coffee machine is started
8+
And I handle everything except the water tank
9+
10+
Scenario: Message "Fill water tank" is displayed after 50 coffees are taken
11+
When I take "50" coffees
12+
Then message "Fill tank" should be displayed
13+
14+
Scenario: It is possible to take 10 coffees after the message "Fill water tank" is displayed
15+
Given I take "60" coffees
16+
Then coffee should be served
17+
When I take a coffee
18+
Then coffee should not be served
19+
20+
Scenario: When the water tank is filled, the message disappears
21+
Given I take "55" coffees
22+
When I fill the water tank
23+
Then message "Ready" should be displayed

features/EatingCucumbersdddfv.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feature: Eating cucumbersdddfv

features/Serve_coffee.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Feature: Serve coffee
2+
As a coffee lover
3+
I can get coffee from the machine
4+
So I can enjoy the rest of the day
5+
6+
Scenario: Simple use
7+
# Well, sometimes, you just get a coffee.
8+
Given the coffee machine is started
9+
When I take a coffee
10+
Then coffee should be served

0 commit comments

Comments
 (0)