It is easy to write code. It is very difficult to write bug free code. To build better software we test.
The general practice is to first do Unit Testing, then integration testing followed by System testing and then acceptance testing. We will limit ourselves to only two kinds here: Unit Testing and Integration Testing.
The first way of testing is to test individual component of your software. This is known as Unit testing. Unit testing is a practice of writing logic to test each component of the code separately. This logic to test each component is called a Test Case. The test cases are written by engineers to check the expected output against actual output of each component. There are various unit testing tools available such as JUnit, PHPUNit, MRUnit and ScalaTest.
The other form of testing is called integration testing. The integration testing is done by test engineers. In integration testing, we test we components are properly integrating. This can be done both manually and in automated way.