Though a person who is infected with HIV will become infectious themselves very rapidly (within a day or so), they will normally have to wait a while before an HIV test will produce an accurate result. The length of time a person should wait before taking an HIV test will depend on the type of test they are taking.
In the vast majority of cases, the standard test that will be offered at an HIV testing centre will be an HIV antibody test. The HIV antibody test looks for antibodies to the virus in a person's blood. For most people these antibodies take 6 weeks to 3 months to develop. In rare cases, it can take up to 6 months. It is extremely rare for a person to take any longer then 6 months to develop detectable antibodies.
Getting tested before 3 months have elapsed may result in an unclear test result, as an infected person may not yet have developed antibodies to HIV. These 3 months are known as the 'window period'. So it is best to wait for at least 3 months after the last time you were at risk before taking the test. Some test centres may recommend testing again at 6 months, just to be extra sure, though in most cases this is not necessary.
If you are waiting to take an HIV antibody test, it is vital that you do not put yourself at risk through further exposures to HIV during this time period. This means you should practise safe sex and not share needles. Any further exposure to HIV may mean an negative HIV test result is not accurate (unless of course you wait another three months after this exposure).
The vast majority of HIV tests that are given in clinics are antibody tests, though other types of test may be available in some clinics.