Depends on the type
There are hearing screens and full blown hearing tests.
Screens may be simple, brief tests where a soft-tipped probe is held gently in your ear
, special sounds are emitted, and the response of the ear is measured by the machine. More formal tests involve wearing headphones in special, quiet booths or rooms and testing your ability to hear various sounds and sound strengths. All are painless!