How to check the gear before renting a bike? I don't own a bicycle. Whenever I go cycling, I would need to rent one. The first thing that I always check is to see if the brakes are working properly.

Sometimes, I have no idea that the gear is faulty until I encounter a steep slope where I need to pedal hard. This may cause the gear to jump or slip if it is faulty. Other times, when I change the gear, the pedalling suddenly becomes inefficient, with constant grinding noises from the gears.

In the end, I try not to change the gears at all to avoid the above problems. I would like to know if there is a way to visually inspect the gear and tell the shop assistant that, "Hey, the bike is faulty!", instead of coming back halfway to do the exchange.
If you're talking about a derailleur-style bike, a quick check is to suspend the rear wheel somehow (sometimes you can hang the nose of the seat on something, eg, or see if the rental place doesn't have a work stand) and crank the pedals with your hand while you shift through the gears.  On a bike with indexed shifters the transitions should be smooth and you should hear no more than very slight "chatter" from the chain once the transition is complete.