Are you able to put all of the Test VMs in a folder, e.g. TestVMs?
Then you could use the following PowerCLI command to stop all of the VMs in the TestVMs folder.
Get-VM -Location TestVMs | Stop-VM
If your folder structure does not allow for this, are all of the Test VMs in there own datastore(s) with none of the Production VMs, you could use
Get-VM -Datastore TestVMDataStore | Stop-VM
Tricky bit will be automating the triggering of the command to run. Do you have any server monitoring tools?