I use Prime95 for testing my CPU and RAM....if it runs for 4 hours and it passes all tests, my computer has never failed after that. It will max my processor and almost all my RAM.
I use 3Dmark06 to test the graphics.
4 hours with Prime95 and 3 runs of 3Dmark06 and my rig is ready for anything
I am not an extreme overclocker so these tests work for me. There are other programs you can use. I know people that will use Orthos and leave it running for 24 hours or more. A lot of performance people like Orthos.
I got them both from Majorgeeks.com, they have good clean software and it's free. I have used that site for years and never had a problem with anything from there. I would post you a link but I'm at work and my military computer won't let me