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