So how does one get tested for insomnia?

No need. You know you have insomnia if you're not sleeping. You don't need a test to know that. Talk to your doctor about the type of insomnia you're having (trouble falling asleep, trouble staying asleep etc). The you can discuss possible causes (drugs, medicines, pain, stress, etc. ) and possible treatments, which can include changes in eating habits, life style, supplements or medications.