Behat Generate

Categories

Component ID

2279613

Component name

Behat Generate

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

Provides a Drush command for generating Behat tests for Node add forms to test that expected fields still exist and validation works. The use case is that you have a site without tests and would like to generate tests for existing content types as easily as possible. Then, in the future, any unexpected changes to those fields (bad update hooks, issues with Feature deployments, etc) should cause a failing test.

The Drush command will check for field types and settings to create a relevant line for the field. The currently supported widget types are:

  • textfield - filled with random text
  • options_select - a random valid option will be selected
  • options_buttons - a random valid radio button will be selected
  • text_textarea - filled with random text and a valid text_format selected
  • text_textarea_with_summary - body and summary filled with random text and a valid text_format selected

If an unknown field/widget type is encountered then a default textfield line will be added for that field. This means the test will fail when run and require manual editing. It is recommended that the random text used be edited to sensible test values.

The command can be run with drush bgn [node_type] to output the test to the command line and, therefore, drush bgn [node_type] > test-file-name.feature to write it straight to file.