I simulate my programs by means of a PLC simulator. For Siemens S7 it is called PLCSIM.
In the PLC code, there is special simulation code the simulates the inputs based on what the outputs does. It is good enough to test the HMI thoroughly, and also if the PLC code works at least 75% OK. You cannot get to 100% because of the complexity of simulating the real world, and also if the problem is your own misconception of how the hardware works, your simulation code will only reflect the misconception.
This simulation definitely cuts down on the time to commision the plant in real life. It is definitely worth the effort.