WordPress core has a set of phpunit tests. You can find documentation on running those tests at http://make.wordpress.org/core/handbook/automated-testing/ . Not many themes or plugins have test suites available, so you'll either have to write your own (and contribute them back to the community!) or build Selenium tests to verify the end result is ok.
For testing your own code, WP Mock might be the best solution.