Simulation is the best option but if u want to check on line whether code is working or not use Debugger for that.
It will be helpful to check on line.
Most probably build a simple hardware to test. Hardware tends to give unexpected weird behaviours. Such as switch where we cant simulate debouncing. Everything seems ok on simulation but harewire on hardware