How do they test for near and farsightedness?

Exam. Various machines or manual lenses methods to neutralize the prescription.