The real problem is weapons often have power and weight limitations that don't apply to trains. So you can build large, power hungry prototypes and test them on a train. Once you work out the bugs found there you then start the miniaturization and lower power versions for where you really want it (or save a lot of money by not doing that work for something that you know can't work anyway)