pregnancy testing

If I had sex 7 days before my period, will I get a period still? Will that mean I'm not pregnant? When can I test?