Do not think that the engine of Hamilton's car was not tested on the "bench". Some people try to understand what happens in the esc and based on that understanding they make their setup what they fine tune on the track.
I agree that the best is to test the car on the track but only a few are as lucky as you are and can go to the track every day. So they have to make their track time more effective.
Actually no it wouldn't be...it would be tested on a dyno and as little as possible to put less wear and tear on the engine.