It's rare for a duff battery to cause problems while the engine is being run as the alternator will supply the electricity needs. The only explanation for a good battery to turn bad in a short space of time would be faulty regulation. The battery should be getting around 14v when the engine is running. Any more than this and it'll boil dry, over heat and short out. The battery shorting will put a massive load on the alternator which in turn will over heat and fail.
While the engine is running, use a DVM (digital volt meter) to test both rectification and regulation. To test rectification, set the DVM to DV Volts and probe across the battery.. You should be getting around the 14v mark. Switch the DVM to AC Volts and probe again, you should be getting 0v. If regulation is the issue, the voltage will be way over 14v DC and will be erratic.
To rule out the starter solenoid, use an insulated screwdriver short the terminals. This will by-pass the circuit and send power direct to the starter motor. If the motor turns the solenoids gone for a burton.. But this wouldn't cause a sudden shut down.
There could be many explanations for it.. Let's hope it's not intermittent as that'll really make you scratch your head!

Most motorcycle problems are caused by the nut that connects the handle bars to the saddle.