A tool for analyzing and debugging intermittent cucumber failures
Need a way to debug and fix intermittent cucumner failures, e.g., a scenario that fails 5 times out of 100.
–
cd pro/ui/tmp
git clone [email protected]:sgonzalez-r7/cuke_lab.git
cd cuke_lab
bundle install
rake spec
–
Repeatablity Lab Example
run/bin prepare NAME
bin/run repeat --name=NAME --features=FEATURE1.feature FEATURE2.feature --cuke_opts='--tags @focus' -n=10
bin/run analysis NAME
–
prepare
- creates a lab directory structurebin/run prepare NAME
labs
└── NAME
├── data
└── results
–
repeat
- runs cucumber n
times and collects the resultsbin/run repeat --name=NAME --features=FEATURE1 FEATURE2 --cuke_opts='--tags @focus' -n=10
Note: FEATURE1
and FEATURE2
are specified relative to features directory, e.g., pro/ui/features
pro-tip - use the --dry-run
option to verify the commands without running cucumber. To see all the command line options for repeat
: bin/run help repeat
Results are collected in the data
directory.
labs
└── NAME
├── data
│ ├── run_00001.json
│ ├── run_00002.json
│ |── run_00003.json
|.. |── ...
|.. └── run_00010.json
└── results
–
analysis
- calcuates the failure distribution of a repeatability experimentThe analysis command reads the cucumber output in the data
directory and calculates the failure distribution. The distribution is written in 2 formats: distribution.json
and distribution.csv
. The json
file is OK for human consumption. The csv
file, however, is meant to be consumed by Excel or some other data analysis tool.
bin/run analysis NAME
labs
└── NAME
├── data
│ ├── run_00001.json
│ ├── run_00002.json
│ |── run_00003.json
|.. |── ...
|.. └── run_00010.json
└── results
├── distribution.json
└── distribution.csv
examples
# distribution.json
[
{
"failure": {
"feature": "/Users/sgonzalez/rapid7/pro/ui/features/sessions/session_collect.feature",
"scenario": "Scenario: Collect Data from a Session",
"step": "When I click on the first Active Session link",
"error_message": "Unable to find css \"#active_sessions\" (Capybara::ElementNotFound)"
},
"n": 5
},
{
"failure": {
"feature": "/Users/sgonzalez/rapid7/pro/ui/features/sessions/session_collect.feature",
"scenario": "Scenario: Collect Data from a Session",
"step": "When I click the \"Collect System Data\" button to submit input",
"error_message": "Unable to find button \"Collect System Data\" (Capybara::ElementNotFound)"
},
"n": 2
},
]
# failure_data.csv
/Users/sgonzalez/rapid7/pro/ui/features/sessions/session_collect.feature,Scenario: Collect Data from a Session,When I click on the first Active Session link,"Unable to find css ""#active_sessions"" (Capybara::ElementNotFound)",1,5
/Users/sgonzalez/rapid7/pro/ui/features/sessions/session_collect.feature,Scenario: Collect Data from a Session,"When I click the ""Collect System Data"" button to submit input","Unable to find button ""Collect System Data"" (Capybara::ElementNotFound)",2,2