So you randomly sample/pick one, or a few (maybe vary it based on the current ray importance or throughput) to test.
So given that you can't sample all lights (efficiently anyway), you have to try and efficiently cull/find lights which are visible to the surface being shaded/lit. Because otherwise you might be sending test occlusion rays to lights that wouldn't even contribute anything even if they weren't occluded.
It's close to impossible to do this perfectly (in an unbiased way, anyway), and even if you do a pretty good job, it's extra computation, and the fact that certain lights are sometimes occluded significantly adds noise to the lighting.
All very doable but are the hard problems with the tech that should be solved before we say that ray tracing is solved.