It could be a hernia, or a pulled groin muscle. When u cough, is there an area on the skin near ur groin area or in ur testicles that pops up??? If yes, you need to see a Doctor ASAP!!! This could be life threatening!!!
If no, since it is causing u so much pain in your groin & testicles, u should still see your Doctor for proper diagnosis. I wouldn't neglect that sensitive part of your body!!!