When to test

When is the right time to test for a pregnancy? A few days after your missed period? Or weeks?