Trial and error is done today. Flight testing often involves trialling various methods to resolve issues.
Generally at the end of a process of many man-years of analysis and careful design, by people with a very deep technical education. Flight testing is at the sharp end of that process, but there is much which sits behind it. For that matter, the design of flight trials is a complex specialist field in its own right.
G