When to test?

What is the earliest a pregnancy test can be taken? I just want advice because it is 4 days before af is due and I am not sure wether to hold off?