Skip to content
Snippets Groups Projects
Commit 6ee74e9a authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

tests(cucumber): fix typos and improve regex

parent 7a438471
No related branches found
No related tags found
1 merge request!68english(cucumber): adds 's'
# Duniter-v2s end2end tests
## cucumber functionnal tests
## Cucumber functionnal tests
We use [cucumber] to be able to describe test scenarios in human language.
......@@ -20,7 +20,7 @@ Feature: Balance transfer
Then dave should have 5 ĞD
```
### create a new functional test
### Create a new functional test
To create a new test scenario, simply create a new file with a name of your choice in the
`/cucumber-features` folder and give it the extension `.feature`.
......@@ -55,8 +55,8 @@ Each scenario is a list of steps. In our context (blockchain), only the `When` a
List of possible actions:
- transfer: `alice send 5 ĞD to bob`
- transfer_ud: `alice send 3 UD to bob`
- transfer: `alice sends 5 ĞD to bob`
- transfer_ud: `alice sends 3 UD to bob`
- transfer_all: `alice sends all her ĞDs to bob`
#### Then
......@@ -96,7 +96,7 @@ Amounts must be expressed as an integer of `ĞD` or `UD`, decimal numbers are no
If you need more precision, you can express amounts in cents of ĞD (write `cĞD`), or in thousandths
of UD (write `mUD`).
### genesis state
### Genesis state
Each scenario bootstraps its own blockchain with its own genesis state.
......@@ -117,17 +117,22 @@ For some scenarios, you may need to perform an action (When) that fails voluntar
### Run cucumber functional tests
The cucumber tests use the last debug binary in your `target` folder. Make sure this binary corresponds to the executable you want to test by running `cargo build` before.
To run the cucumber tests, you will need to have the rust toolchain installed locally.
To run all the scenarios (there are many) use the command: `cargo cucumber`
You can filter the `.feature` files to run with the option `i`, for instante:
You can filter the `.feature` files to run with the option `i`, for instance:
```
cargo cucumber -i monetary*
```
Will only run `.feature` files that start with `"monetary"`.
will only run `.feature` files that start with `"monetary"`.
The features will be tested in parallel and logs files will be written in the `end2end-tests` folder.
If you get an `Error: Timeout`, look at the logs to understand why Duniter did not launch successfully. You can also set the environment variable `DUNITER_END2END_TESTS_SPAWN_NODE_TIMEOUT` to increase the timeout for node spawn.
### Contribute to the code that runs the tests
......
Feature: Balance transfer
Scenario: Create a new account with enough founds
When alice send 5 ĞD to dave
Scenario: Create a new account with enough funds
When alice sends 5 ĞD to dave
Then dave should have 5 ĞD
When 1 block later
"""
......@@ -9,13 +9,13 @@ Feature: Balance transfer
"""
Then dave should have 2 ĞD
Scenario: Create a new account without enough founds then retry with enough founds
When alice send 2 ĞD to eve
Scenario: Create a new account without enough funds then retry with enough funds
When alice sends 2 ĞD to eve
Then eve should have 2 ĞD
When 1 block later
"""
The blockchain should automatically destroy Evec account
because Eve not have enough founds to pay the new account tax
The blockchain should automatically destroy Eve account
because Eve does not have enough funds to pay the new account tax
"""
Then eve should have 0 ĞD
When alice send 5 ĞD to eve
......@@ -27,7 +27,7 @@ Feature: Balance transfer
Then eve should have 2 ĞD
@ignoreErrors
Scenario: Create a new account without any founds
Scenario: Create a new account without any funds
Then eve should have 0 ĞD
When eve send 0 ĞD to alice
Then alice should have 10 ĞD
......
......@@ -119,7 +119,7 @@ fn parse_amount(amount: u64, unit: &str) -> (u64, bool) {
}
}
#[given(regex = r"([a-zA-Z]+) have (\d+) (ĞD|cĞD|UD|mUD)")]
#[given(regex = r"([a-zA-Z]+) ha(?:ve|s) (\d+) (ĞD|cĞD|UD|mUD)")]
async fn who_have(world: &mut DuniterWorld, who: String, amount: u64, unit: String) -> Result<()> {
// Parse inputs
let who = AccountKeyring::from_str(&who).expect("unknown to");
......@@ -149,7 +149,7 @@ async fn n_blocks_later(world: &mut DuniterWorld, n: usize) -> Result<()> {
Ok(())
}
#[when(regex = r"([a-zA-Z]+) send (\d+) (ĞD|cĞD|UD|mUD) to ([a-zA-Z]+)")]
#[when(regex = r"([a-zA-Z]+) sends? (\d+) (ĞD|cĞD|UD|mUD) to ([a-zA-Z]+)")]
async fn transfer(
world: &mut DuniterWorld,
from: String,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment