<p>I'm just getting into unit testing, and have written some short tests to check if function called isPrime() works correctly.</p>

<p>I've got a test that checks that the function works, and have some test data in the form of some numbers and the expected return value.</p>

<p>How many should I test? How do I decide on which to test? What's the best-practices here?</p>

<p>One approach would be to generate 1000 primes, then loop through them all, another would be to just select 4 or 5 and test them. What's the correct thing to do?</p>

Ask yourself. What EXACTLY do I want to test. And test the most important. Test to make sure it basically does what you are expecting it to do in the expected cases.
Testing all those nulls and edge-cases - I - don't think is real, too time consuming and someone needs to maintain that later! 
And...your test code should be simple enough so that you do not need to test your test code!
If you want to check that your function correctly applied the algorithm and works in general - probably will be enough some primes.
If you want prove that the method for finding primes is CORRECT - 100000 primes will not be enough :)
But you don't want to test the latter (probably)...
Only you know what you want to test! :)
PS I thnik using loops in unit tests is not always wrong but I would think twice before doing that. Test code should be VERY simple. What if something goes wrong and there is a bug in your test???? :)
However, you should try to avoid test code duplication as regular code duplication. Someone has to maintain test code.
PEOPLE PLEASE COMMENT WHY YOU THINK THIS WAS WORTH TWO DOWNVOTES :)