That's where I would start.
Because it happens sporadically you will have a hard time testing the battery. Yes, the places like Autozone can throw it on a device and say it checks out, but it doesn't do a good job detecting cells that are starting to go out.
Also, unless you want to climb under the car and whack the starter with a hammer to unstick a potential stuck starter, then I would start with the battery, and then do the starter.
An alternator is easy to test if you have a digital multi-meter. But I am highly doubtful it's the alternator because it is random and you get zero click or zero crank. If it was a bad alternator I'd expect a weak crank or at least clicks. Easy way to test this is to get the car started and while it is running, disconnect the negative cable. If the car still runs while disconnected, the alternator is fine. Otherwise you can get a digital multimeter or have autozone test it. While running the voltage on the battery should be ~13.5-14.5v.