Those who would like to rule out a possible HIV infection should get tested, at the earliest, six weeks after the last risk situation. Only then can the HIV test reliably rule out an HIV infection.
Rapid test needs longer: The rapid test does not detect the HIV virus itself in the blood but rather the antibodies that the immune system forms to fight the virus. For some people, it takes up to three months for these antibodies to form and become detectable.
So a “negative” test result shortly after risk of infection does not necessary mean that the person is not infected with HIV. It only indicates that there are still no antibodies and/or antigens in the blood.