Most piggies will pee on demand if the vet presses their bladder a little, that's usually enough to test. In an emergency or to ensure the urine comes straight from the bladder and isnt contaminated with bum bacteria they might sedate the piggy and put a needle into the bladder, but that's quite unusual and for more advanced tests- usually just pressing on the bladder as part of the routine external examination is enough to make piggy pee on the table!
Red off-on pees and squeaking when peeing is typical for the onset of a UTI or cystitis and not so much for a stone or sludge.
A urine test at the vets will usually check for blood in the pee (note that expressing pee will usually cause a tiny amount of bleeding), protein levely (raised levels are an indication of an infection), and the may also test for the presence of crystals and bacteria.

if you want to bring some collected, preferably fresh urine for testing, here are tips: How To Collect A Urine Sample