You should take an HIV test if you feel you have been at risk. 

After initial infection there is a "window period" during which HIV cannot be detected by a test, this period can last from a few weeks up to 3 months. HIV diagnosis tests work by detecting HIV antibodies made by your immune system as a reaction to being infected with HIV. Even though HIV will be present in the blood stream It can take your body many weeks to produce enough antibodies to show up in a diagnosis test. If you are tested during the window period it may incorrectly show a negative result. If you're not sure about this speak with your doctor or sexual health nurse.

Once the window period has passed, the antibodies will be detectable in your blood and a definitive HIV diagnosis, whether positive or negative, can be confirmed. 

However, if you think you have been at risk do not wait until the window period has passed. Contact your nearest sexual health clinic or GP who should be able to advise you on testing options.