Formatting Cucumber Feature file
Solution 1
If you're using IntelliJ go to Code>Reformat code
Solution 2
As Joe says, the --autoformat
feature isn't available any more.
I found that cucumber --dry-run --format pretty --quiet --no-color
pretty much gives you what you want, although you'd have to do some string-wrangling to write back to the files.
Solution 3
I created this with a similar problem in mind. Paste your code into the editor, hit Ctrl+Enter and your table pipes will be aligned. Tidy Gherkin Chrome App
Solution 4
If you're using IntelliJ, there is also a good plugin called Pipe Table Formatter!
:)
Solution 5
cucumber --autoformat . -t @myuglytests
cucumber -help
-a, --autoformat DIR Reformats (pretty prints) feature files and write them to DIRECTORY.
Be careful if you choose to overwrite the originals.
Implies --dry-run --format pretty.
Manish
Updated on August 03, 2022Comments
-
Manish over 1 year
I extensively use Data tables in cucumber feature file. Data Tables are mostly dump of Database table which i export in pipe delimted format and not properly aligned.
Is there any option in Cucumber-JVM that will auto align DataTables ?
-
Joe almost 9 yearsIt's worth pointing out that this option has been removed in Cucumber 2.0. That issue references the "Gherkin CLI" which has a
reformat
command, but that CLI was removed in v2.2.8. So it would appear that there is no longer any way to achieve this?