How do I test my code in Drupal 8? 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)
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.