Yes, it is illegal to brake-test. The car driver behind, who is a victim of the situation, may accelerate the speed or change lanes to avoid the car in front and cause accidents.