How to retrieve all available routes in an application?

I want to quickly improve test coverage for my project by doing some basic tests. In specific, I had the idea to test whether all Controller actions return a non-500 status code since this is something that all actions should satisfy. Obviously, this doesn’t test real functionality, but it’s better than no tests at all.

The problem that I have is that I am not sure how to retrieve all possible routes from the router. I’ve looked at several methods on the router, but they don’t return an array of available routes, or at least not in a format that I comprehend.

Can someone please explain how to retrieve all available routes such that I can do $this->dispatch($route) for each of them?