0

I created a Drupal 8 module and I would like know what is the best practice for testing my code?

For example, if I use hook_user_login(), how I can try my code without login/logout every time and how do I display my var_dump() result? (var_dump result not displayed due to redirection after login)

  • "how I can try my code without login/logout every time" these are usually called "unit tests". – Letharion Jan 20 '15 at 6:56
3

Use Devel for most of the (There is a dev version for Drupal 8) visual testing and seeing output of most of the render arrays (DPM function will retain the array if there is redirect so it will output in those cases). Plus other variables can be output. You can use the old school tail -f drupal_debug.txt by using dd() or just output in Krumo to the screen with dpm(). You can find out more about Devel by visiting the project page.

Also you can run tests using Drupal SimpleTest and find out more about how to implement SimpleTest in the Drupal Examples which does have tests examples for 7 and 8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.